]> diplodocus.org Git - nmh/commitdiff
Limit mhparam's exit status to 120 missing components.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sat, 18 Feb 2017 14:47:56 +0000 (14:47 +0000)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sat, 18 Feb 2017 14:47:56 +0000 (14:47 +0000)
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.

man/mhparam.man
test/mhparam/test-mhparam
uip/mhparam.c

index 07da4ccd31d0f7f0276663f5d2d2c9b6e1650676..df1de43e5f7d250866bf73b1dc821c7a244137c1 100644 (file)
@@ -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
index a75e19916111c044b294d8796ce65fac869df19f..a2130ba7f08655223e14589728165837d72ca06a 100755 (executable)
@@ -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.
index 242333407f893680a4656051aaa1b4f524b58718..c52410c0c17a17e763d3857649a7642b277f7cd2 100644 (file)
@@ -250,7 +250,7 @@ main(int argc, char **argv)
                    printf("%s: ", comps[i]);
 
                puts(value);
-           } else
+           } else if (missed < 120)
                missed++;
        }
     }