On 06/03/2014 12:28 PM, Bernhard Voelker wrote:
> On 06/03/2014 11:56 AM, Pádraig Brady wrote:
>> There is an inconsistency here with the (GNU) options.
>> Now I don't think anyone would ever be using `env true --version > blah`
>> in a script, but it would be better to be consistent here
>> and have the exit code dependent on the name rather than the environment.
> 
> I don't have a strong preference whether to change true or false,
> but I'm fine with your choice.
> 
>> I also see that the test script for `false` was only
>> checking the shell builtin :/
> 
> Good catch!
> 
>> The attached fixes up both issues in your name.
> 
> Thanks!
> Should this be mentioned in NEWS, too?

Not worth it I think since not a practical issue.

>> OK to push?
> 
> yes, sure, but ... wait, a test was failing; the following
> fixes it:
> 
> diff --git a/gnulib b/gnulib
> index a10acfb..2f40bc5 160000
> --- a/gnulib
> +++ b/gnulib
> @@ -1 +1 @@
> -Subproject commit a10acfb1d2118f9a180181d3fed5399dbbe1df3c
> +Subproject commit 2f40bc523412742dac387b37d70b5a7f5d8363cc
> diff --git a/tests/misc/help-version.sh b/tests/misc/help-version.sh
> index 4bc02d8..50c05a2 100755
> --- a/tests/misc/help-version.sh
> +++ b/tests/misc/help-version.sh
> @@ -92,6 +92,13 @@ for lang in C fr da; do
> 
>      # Make sure they fail upon 'disk full' error.
>      if test -w /dev/full && test -c /dev/full; then
> +      # true succeeds with --help or --version even if write fails.
> +      if test $i = true; then
> +        env $i --help >/dev/full || fail=1
> +        env $i --version >/dev/full || fail=1

The two lines above are already done in the separated test,
so we can just continue here. Also it's better to have
the continue and the special case for false(1) above this.
Also I see that the interations for LC_MESSAGES only for false
are redundant here. So I've cleaned up all that in the attached.

OK to push?

thanks,
Pádraig.
>From afa0848d167d5b0abbe843caf7a521bcff9170f4 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <m...@bernhard-voelker.de>
Date: Tue, 3 Jun 2014 10:50:09 +0100
Subject: [PATCH] true: always exit with status 0 even if can't write

* src/true.c (main): Init exit_failure appropriately.
* tests/misc/false-status.sh: Fix so we're testing
the tool and not the shell builtin.  Add a case
for true also.
* tests/misc/help-version.sh: Skip /dev/full test
for true as well as false.  Also remove the interations
for different LC_MESSAGES, as this was only done for false(1)
and also translations are not honored in the test directory
so would need separate handling in any case.
---
 src/true.c                 |    1 +
 tests/misc/false-status.sh |   12 ++++++--
 tests/misc/help-version.sh |   65 ++++++++++++++++++++-----------------------
 3 files changed, 40 insertions(+), 38 deletions(-)

diff --git a/src/true.c b/src/true.c
index 219f98c..4ac319b 100644
--- a/src/true.c
+++ b/src/true.c
@@ -64,6 +64,7 @@ main (int argc, char **argv)
       bindtextdomain (PACKAGE, LOCALEDIR);
       textdomain (PACKAGE);
 
+      initialize_exit_failure (EXIT_STATUS);
       atexit (close_stdout);
 
       if (STREQ (argv[1], "--help"))
diff --git a/tests/misc/false-status.sh b/tests/misc/false-status.sh
index b943040..fc0999a 100755
--- a/tests/misc/false-status.sh
+++ b/tests/misc/false-status.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 # ensure that false exits nonzero even with --help or --version
+# and vice versa for true
 
 # Copyright (C) 2003-2014 Free Software Foundation, Inc.
 
@@ -17,9 +18,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ false
+print_ver_ false true
 
-false --version > /dev/null && fail=1
-false --help > /dev/null && fail=1
+env false --version > /dev/null && fail=1
+env false --help > /dev/null && fail=1
+
+if test -w /dev/full && test -c /dev/full; then
+  env true --version > /dev/full || fail=1
+  env true --help > /dev/full || fail=1
+fi
 
 Exit $fail
diff --git a/tests/misc/help-version.sh b/tests/misc/help-version.sh
index 4bc02d8..50dd955 100755
--- a/tests/misc/help-version.sh
+++ b/tests/misc/help-version.sh
@@ -70,43 +70,38 @@ done
 test "x$v" = "x$VERSION" \
   || fail_ "--version-\$VERSION mismatch"
 
-for lang in C fr da; do
-  for i in $built_programs; do
-
-    # Skip 'test'; it doesn't accept --help or --version.
-    test $i = test && continue;
-
-    # false fails even when invoked with --help or --version.
-    if test $i = false; then
-      env LC_MESSAGES=$lang $i --help >/dev/null && fail=1
-      env LC_MESSAGES=$lang $i --version >/dev/null && fail=1
-      continue
-    fi
+for i in $built_programs; do
 
-    # The just-built install executable is always named 'ginstall'.
-    test $i = install && i=ginstall
-
-    # Make sure they exit successfully, under normal conditions.
-    env $i --help    >/dev/null || fail=1
-    env $i --version >/dev/null || fail=1
-
-    # Make sure they fail upon 'disk full' error.
-    if test -w /dev/full && test -c /dev/full; then
-      env $i --help    >/dev/full 2>/dev/null && fail=1
-      env $i --version >/dev/full 2>/dev/null && fail=1
-      status=$?
-      test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//")
-      eval "expected=\$expected_failure_status_$prog"
-      test x$expected = x && expected=1
-      if test $status = $expected; then
-        : # ok
-      else
-        fail=1
-        echo "*** $i: bad exit status '$status' (expected $expected)," 1>&2
-        echo "  with --help or --version output redirected to /dev/full" 1>&2
-      fi
+  # Skip 'test'; it doesn't accept --help or --version.
+  test $i = test && continue
+
+  # false fails even when invoked with --help or --version.
+  # true succeeds even when failing to write output.
+  test $i = true || test $i = false && continue
+
+  # The just-built install executable is always named 'ginstall'.
+  test $i = install && i=ginstall
+
+  # Make sure they exit successfully, under normal conditions.
+  env $i --help    >/dev/null || fail=1
+  env $i --version >/dev/null || fail=1
+
+  # Make sure they fail upon 'disk full' error.
+  if test -w /dev/full && test -c /dev/full; then
+    env $i --help    >/dev/full 2>/dev/null && fail=1
+    env $i --version >/dev/full 2>/dev/null && fail=1
+    status=$?
+    test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//")
+    eval "expected=\$expected_failure_status_$prog"
+    test x$expected = x && expected=1
+    if test $status = $expected; then
+      : # ok
+    else
+      fail=1
+      echo "*** $i: bad exit status '$status' (expected $expected)," 1>&2
+      echo "  with --help or --version output redirected to /dev/full" 1>&2
     fi
-  done
+  fi
 done
 
 bigZ_in=bigZ-in.Z
-- 
1.7.7.6

Reply via email to