coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coreutils-8.14.116-1e18d on HP-UX 11.00


From: Jim Meyering
Subject: Re: coreutils-8.14.116-1e18d on HP-UX 11.00
Date: Mon, 09 Jan 2012 10:15:22 +0100

Voelker, Bernhard wrote:
> Bruno Haible wrote:
>
>> Hi Jim,
>> 
>> > How about this?
>> > 
>> >      if (diff -u out out < /dev/null) > /dev/null 2>&1; then
>> > 
>> > As usual, since your name is on it, I'll wait for an ACK
>> > before pushing it.
>> 
>> Yes, that's just as good. Thanks!
>
> Do we really need a subshell here?

Yes.

> This should be enough, right?
>
>     if diff -u out out < /dev/null > /dev/null 2>&1; then

With that, when diff does not exist, the shell's diagnostic
is not always redirected to /dev/null.

>From "info autoconf":

     On the other hand, some shells, such as Solaris or FreeBSD
  `/bin/sh', warn about missing programs before performing redirections.
  Therefore, to silently check whether a program exists, it is necessary
  to perform redirections on a subshell:

       $ /bin/sh -c 'nosuch 2>/dev/null'
       nosuch: not found
       $ /bin/sh -c '(nosuch) 2>/dev/null'
       $ bash -c 'nosuch 2>/dev/null'

However, ...
the only way we reach the code you've mentioned is if the shell has
passed certain tests that are designed to exclude inadequate shells,
including at least Solaris 10's /bin/sh.

I suspect that any shell we accept is modern enough to perform the
redirection as expected, so I'll go ahead and make the change you suggest.
Besides, it's only the test of the testing framework, and the penalty
for failure is a mere "diff not found" diagnostic on some old system.

I confirmed that at least on Solaris 10, it works as desired,
even when (somehow) you don't have diff in your shell's search path.

I've pushed this:

>From 89c006fbb40a0455ad309155be38277490c0b94f Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 9 Jan 2012 10:12:18 +0100
Subject: [PATCH] test-init.sh: avoid a subshell

* tests/test-init.sh: Remove protective subshell.
Suggested by Bernhard Voelker.  While a subshell is normally
required to protect against older shells (Solaris, FreeBSD) that
warn about a missing program before performing redirection, the
shell-selection tests performed by init.sh probably exclude any
offending shell.
---
 ChangeLog          |   10 ++++++++++
 tests/test-init.sh |    2 +-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 08468ce..9048131 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-01-09  Jim Meyering  <address@hidden>
+
+       test-init.sh: avoid a subshell
+       * tests/test-init.sh: Remove protective subshell.
+       Suggested by Bernhard Voelker.  While a subshell is normally
+       required to protect against older shells (Solaris, FreeBSD) that
+       warn about a missing program before performing redirection, the
+       shell-selection tests performed by init.sh probably exclude any
+       offending shell.
+
 2012-01-08  Bruno Haible  <address@hidden>

        setlocale tests: Avoid test failure on Solaris 11 2011-11.
diff --git a/tests/test-init.sh b/tests/test-init.sh
index 3368a99..c644609 100755
--- a/tests/test-init.sh
+++ b/tests/test-init.sh
@@ -63,7 +63,7 @@ EOF
   sed 's/      .*//;/^@@/d' out > k && mv k out

   # Compare against expected output only if compare is using diff -u.
-  if (diff -u out out < /dev/null) > /dev/null 2>&1; then
+  if diff -u out out < /dev/null > /dev/null 2>&1; then
     compare exp out || fail=1
   fi
   case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
-- 
1.7.9.rc0.2.g4b783



reply via email to

[Prev in Thread] Current Thread [Next in Thread]