From: Ralph Corderoy Date: Sat, 18 Feb 2017 14:47:56 +0000 (+0000) Subject: Limit mhparam's exit status to 120 missing components. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/e8eb3afba50cbec8d1aeabcf85a06084977d54cd?ds=sidebyside;hp=66fa74b004d50df011eecdeac09b5e4f59181e12 Limit mhparam's exit status to 120 missing components. Otherwise, 126 and 127 would clash with bash and zsh's use. Higher than 127 would look like signals. And 256 would wrap to a falsely succesful zero. --- diff --git a/man/mhparam.man b/man/mhparam.man index 07da4ccd..df1de43e 100644 --- a/man/mhparam.man +++ b/man/mhparam.man @@ -153,7 +153,11 @@ is also useful in backquoted operations: .fi .SH "EXIT STATUS" .B mhparam -returns the number of components that were not found. +returns the number of components that were not found, +but limits just the return value to 120 to avoid ambiguity, +e.g.\& 127 is used by shells to indicate `command not found', +and 256 would wrap to 0, falsely indicating success. +. .SH FILES .fc ^ ~ .nf diff --git a/test/mhparam/test-mhparam b/test/mhparam/test-mhparam index a75e1991..a2130ba7 100755 --- a/test/mhparam/test-mhparam +++ b/test/mhparam/test-mhparam @@ -165,6 +165,17 @@ mhparam path context nonexistent1 nonexistent2 nonexistent3 >/dev/null run_test "echo $?" 3 set -e +# And clips their numbers to avoid a misleading exit value. +while read use want; do + r=0 + mhparam `yes nonexistent | sed ${use}q` || r=$? + run_test "echo $r" $want +done <<\E +119 119 +120 120 +121 120 +E + # mhparam -debug # Some of its output depends on configure options, so don't bother to # check for correctness here. diff --git a/uip/mhparam.c b/uip/mhparam.c index 24233340..c52410c0 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -250,7 +250,7 @@ main(int argc, char **argv) printf("%s: ", comps[i]); puts(value); - } else + } else if (missed < 120) missed++; } }