commit: bd4681110f7de45133903fb0d8194b075f7cc73f
parent 9ed44af08a2e230c4a88f291206098f8e9aac3cc
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 29 Aug 2024 00:37:52 +0200
cmd/mktemp: properly support -q option
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/cmd/mktemp.c b/cmd/mktemp.c
@@ -73,7 +73,9 @@ main(int argc, char *argv[])
char *dir = mkdtemp(template);
if(dir == NULL)
{
- fprintf(stderr, "mktemp: Failed creating random directory: %s\n", strerror(errno));
+ if(!o_quiet)
+ fprintf(stderr, "mktemp: Failed creating random directory: %s\n", strerror(errno));
+
return 1;
}
@@ -85,7 +87,8 @@ main(int argc, char *argv[])
int fd = mkstemp(template);
if(fd < 0)
{
- fprintf(stderr, "mktemp: Failed creating random file: %s\n", strerror(errno));
+ if(!o_quiet) fprintf(stderr, "mktemp: Failed creating random file: %s\n", strerror(errno));
+
return 1;
}
@@ -93,7 +96,8 @@ main(int argc, char *argv[])
if(close(fd) < 0)
{
- fprintf(stderr, "mktemp: Failed closing file descriptor: %s\n", strerror(errno));
+ if(!o_quiet) fprintf(stderr, "mktemp: Failed closing file descriptor: %s\n", strerror(errno));
+
return 1;
}