logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git
commit: a18473d0080d142ac9514a7f22e8d3ce45759da0
parent 491288e1bc366768eefc32ac524e2e7acfdf9111
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 20 Sep 2024 03:12:55 +0200

cmd/mktemp: unify error message formatting

Diffstat:

Mcmd/mktemp.c12+++++++-----
Mtest-cmd/mktemp.sh2+-
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cmd/mktemp.c b/cmd/mktemp.c @@ -50,7 +50,7 @@ main(int argc, char *argv[]) } else if(argc > 1) { - fprintf(stderr, "mktemp: Only one template argument is supported, got %d\n", argc); + fprintf(stderr, "mktemp: error: Only one template argument is supported, got %d\n", argc); return 1; } @@ -59,7 +59,7 @@ main(int argc, char *argv[]) if(chdir(tmpdir) < 0) { fprintf(stderr, - "mktemp: Failed changing directory into tmpdir '%s': %s\n", + "mktemp: error: Failed changing directory into tmpdir '%s': %s\n", tmpdir, strerror(errno)); return 1; @@ -74,7 +74,7 @@ main(int argc, char *argv[]) if(dir == NULL) { if(!o_quiet) - fprintf(stderr, "mktemp: Failed creating random directory: %s\n", strerror(errno)); + fprintf(stderr, "mktemp: error: Failed creating random directory: %s\n", strerror(errno)); return 1; } @@ -87,7 +87,8 @@ main(int argc, char *argv[]) int fd = mkstemp(template); if(fd < 0) { - if(!o_quiet) fprintf(stderr, "mktemp: Failed creating random file: %s\n", strerror(errno)); + if(!o_quiet) + fprintf(stderr, "mktemp: error: Failed creating random file: %s\n", strerror(errno)); return 1; } @@ -96,7 +97,8 @@ main(int argc, char *argv[]) if(close(fd) < 0) { - if(!o_quiet) fprintf(stderr, "mktemp: Failed closing file descriptor: %s\n", strerror(errno)); + if(!o_quiet) + fprintf(stderr, "mktemp: error: Failed closing file descriptor: %s\n", strerror(errno)); return 1; } diff --git a/test-cmd/mktemp.sh b/test-cmd/mktemp.sh @@ -70,5 +70,5 @@ t_mkdtemp dir '-d' t_mkdtemp dir_template '-d template.XXXXXX' t_mkdtemp dir_tmpdir '-dt' -t --exit=1 templ2 'foo bar' 'mktemp: Only one template argument is supported, got 2 +t --exit=1 templ2 'foo bar' 'mktemp: error: Only one template argument is supported, got 2 '