From e8e8dacb23af84be45fa2ae69854437f2f5112ec Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:31:56 +0800 Subject: [PATCH] test: exit(1) for no argument (#520) * The wording of standards document is "exit 1 if expression evaluates to false, or if expression is missing" * A usage example might be "[ $xyz ]" in a shell script; unquoted variable will substitute to empty string if not set so no argument is passed to test command * 4 different versions of test exit(1) consistently for this case: pdksh builtin, bash builtin, /usr/bin/test on Linux and /bin/test on OpenBSD 1. https://pubs.opengroup.org/onlinepubs/009695399/utilities/test.html --- bin/test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/test b/bin/test index 4608bf7a..6a8266dc 100755 --- a/bin/test +++ b/bin/test @@ -228,7 +228,7 @@ sub test (@) { return ($@) ? undef : 0+$result; } -exit(2) if (@ARGV == 0); +exit(1) if (@ARGV == 0); my $rc = test @ARGV; ## For command-lines, zero is success and non-zero is false, so