From: David Levine Date: Sat, 26 Aug 2017 11:30:30 +0000 (-0400) Subject: Changed failure exit status of mkstemp(1) from 255 to 1. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/96b4a2bc9d64b14a9dfd2b432a5de2fc17044933?ds=sidebyside;hp=d75a77322da611cee356d85e7e016744a8edf180 Changed failure exit status of mkstemp(1) from 255 to 1. For consistency, on Ralph's suggestion. --- diff --git a/man/mh-mkstemp.man b/man/mh-mkstemp.man index 24a040c6..43ba43ea 100644 --- a/man/mh-mkstemp.man +++ b/man/mh-mkstemp.man @@ -59,7 +59,7 @@ If .B mkstemp successfully creates the temporary file, it prints the file name on standard output and exits with status 0. On failure, it prints a -diagnostic message on standard error and exits with status 255. +diagnostic message on standard error and exits with status 1. .SH "PROFILE COMPONENTS" None .SH "SEE ALSO" diff --git a/test/mkstemp/test-mkstemp b/test/mkstemp/test-mkstemp index 97896e48..8e0eb830 100755 --- a/test/mkstemp/test-mkstemp +++ b/test/mkstemp/test-mkstemp @@ -21,7 +21,7 @@ actual="$MH_TEST_DIR"/$$.actual mkstemp="${MH_LIBEXEC_DIR}/mkstemp" -check_exit '-eq 255' $mkstemp - +check_exit '-eq 1' $mkstemp - $mkstemp -help | grep suffix >/dev/null && has_mkstemps=1 || has_mkstemps=0 diff --git a/uip/mkstemp.c b/uip/mkstemp.c index b7acbb14..7dc80656 100644 --- a/uip/mkstemp.c +++ b/uip/mkstemp.c @@ -44,7 +44,7 @@ main(int argc, char *argv[]) { process_args(argc, argv, &directory, &prefix, &suffix); if ((template = build_template(directory, prefix, suffix)) == NULL) { - return -1; + return 1; } if ((suffix_len = strlen(suffix)) > 0) { @@ -64,7 +64,7 @@ main(int argc, char *argv[]) { free(template); - return fd >= 0 ? 0 : -1; + return fd >= 0 ? 0 : 1; } @@ -152,7 +152,7 @@ process_args(int argc, char **argv, const char **directory, NMH_UNUSED(suffix); # endif /* ! HAVE_MKSTEMPS */ - if (nmh_init(argv[0], 2)) { done(NOTOK); } + if (nmh_init(argv[0], 2)) { done(1); } arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; @@ -164,12 +164,12 @@ process_args(int argc, char **argv, const char **directory, switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(NOTOK); + done(1); case UNKWNSW: inform("-%s unknown", cp); (void) snprintf(buf, sizeof buf, "%s [switches]", invo_name); print_help(buf, switches, 1); - done(NOTOK); + done(1); case HELPSW: (void) snprintf(buf, sizeof buf, "%s [switches]", invo_name); print_help(buf, switches, 1); @@ -237,7 +237,7 @@ process_args(int argc, char **argv, const char **directory, exit(0); default: (void) fprintf(stderr, usage, argv[0]); - exit(-1); + exit(1); } } }