]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid side effects of $SHELL environment variable
authorPádraig Brady <P@draigBrady.com>
Fri, 3 Jul 2015 03:44:05 +0000 (04:44 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 3 Jul 2015 12:02:21 +0000 (13:02 +0100)
Since non interactive shells don't generally set $SHELL,
its value is propagated through the tests and may cause issues;
for example if $SHELL implicitly adjusts $PATH when run.
Instead we set $SHELL to that determined by the posix-shell module,
and use that consistently for all test sub scripts,
including those created thorugh the `split --filter` command.

* tests/local.mk: Explicitly set $SHELL to $(PREFERABLY_POSIX_SHELL)
which defaults to $CONFIG_SHELL and thus usually /bin/sh.
* tests/envvar-check: Remove bash environment variables with
side effects, in case /bin/bash was selected for $SHELL.
* tests/misc/help-version.sh: Remove redundant initialization of $SHELL.
* tests/install/strip-program.sh: Use $SHELL for sub script.
* tests/misc/sort-compress-hang.sh: Likewise.
* tests/misc/sort-compress-proc.sh: Likewise.
* tests/misc/sort-compress.sh: Likewise.
* tests/misc/timeout-group.sh: Likewise.
* tests/rm/fail-eperm.xpl: Remove redundant elision of bash env vars.
* tests/misc/pwd-long.sh: Likewise.

tests/envvar-check
tests/install/strip-program.sh
tests/local.mk
tests/misc/help-version.sh
tests/misc/pwd-long.sh
tests/misc/sort-compress-hang.sh
tests/misc/sort-compress-proc.sh
tests/misc/sort-compress.sh
tests/misc/timeout-group.sh
tests/rm/fail-eperm.xpl

index 76becbf4baed42fe8d85dea0a90897408e456104..28d95f30506a8482910b06b63bad49e7e7510d20 100644 (file)
@@ -28,12 +28,14 @@ vars='
   _STDBUF_E
   _STDBUF_I
   _STDBUF_O
+  BASH_ENV
   BLOCKSIZE
   BLOCK_SIZE
   CDPATH
   COLUMNS
   DF_BLOCK_SIZE
   DU_BLOCK_SIZE
+  ENV
   LANGUAGE
   LS_BLOCK_SIZE
   LS_COLORS
index 7ac2165ea7628b7310578351ff348b99b27fa0b2..103f54943f3cd35486221f92a519c9aa62403c3e 100755 (executable)
@@ -22,7 +22,7 @@ print_ver_ ginstall
 working_umask_or_skip_
 
 cat <<EOF > b || framework_failure_
-#!$PREFERABLY_POSIX_SHELL
+#!$SHELL
 sed s/b/B/ \$1 > \$1.t && mv \$1.t \$1
 EOF
 chmod a+x b || framework_failure_
index 3cd8f92c672684cfa149f8228e52e5a1e7df68a4..7df04dac1b5199f16947ff62de0dd31d152fb0bc 100644 (file)
@@ -79,7 +79,7 @@ TESTS_ENVIRONMENT =                           \
   MAKE=$(MAKE)                                 \
   PACKAGE_VERSION=$(PACKAGE_VERSION)           \
   PERL='$(PERL)'                               \
-  PREFERABLY_POSIX_SHELL='$(PREFERABLY_POSIX_SHELL)' \
+  SHELL='$(PREFERABLY_POSIX_SHELL)'            \
   ; test -d /usr/xpg4/bin && PATH='/usr/xpg4/bin$(PATH_SEPARATOR)'"$$PATH"; \
   PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
   ; 9>&2
index e0dd721f944300477052822582a6b9c27176f9cd..78150374da282ee0527e542cae27322cd6577f55 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Ensure that $SHELL is set to *some* value and exported.
-# This is required for dircolors, which would fail e.g., when
-# invoked via debuild (which removes SHELL from the environment).
-test "x$SHELL" = x && SHELL=/bin/sh
-export SHELL
-
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
 # Terminate any background processes
index 927fdcff2a8caec1da068c31a894565244ede813..3ced777aec41ece13c42b1fb43096b86c6fedf5f 100755 (executable)
@@ -56,7 +56,6 @@ sub normalize_to_cwd_relative ($$$)
 }
 
 # Set up a safe, well-known environment
-delete @ENV{qw(BASH_ENV CDPATH ENV)};
 $ENV{IFS}  = '';
 
 # Taint checking requires a sanitized $PATH.  This script performs no $PATH
index 9cfd6cc9045104c2d78c442d330f0cde2bfc95aa..dc101fea84f921746ba3d4085dcadf7d2059a453 100755 (executable)
@@ -20,8 +20,8 @@
 print_ver_ sort
 very_expensive_
 
-cat <<\EOF >compress || framework_failure_
-#!/bin/sh
+cat <<EOF >compress || framework_failure_
+#!$SHELL
 tr 41 14 || exit
 touch ok
 EOF
index 4ad42d51487fa0acc3a961ecc657b9bebfa014e1..05017a54fa2a3c948bdf88e8ca345fc0002c1f6a 100755 (executable)
@@ -32,8 +32,9 @@ insize=$(stat -c %s - <in) || fail=1
 # This compressor's behavior is adjustable via environment variables.
 export PRE_COMPRESS=
 export POST_COMPRESS=
-cat <<\EOF >compress || framework_failure_
-#!/bin/sh
+
+printf '%s\n' '#!'"$SHELL" >compress || framework_failure_
+cat <<\EOF >>compress || framework_failure_
 eval "$PRE_COMPRESS"
 tr 41 14 || exit
 eval "$POST_COMPRESS"
index 605d539ba1b4db9f6af25ad8baef956254759df2..584110e129d3a5336c3d79af33a49c1326cbe8f0 100755 (executable)
@@ -27,8 +27,8 @@ sort -S 1k in > out || fail=1
 compare exp out || fail=1
 
 # Create our own gzip program that will be used as the default
-cat <<\EOF > gzip || fail=1
-#!/bin/sh
+cat <<EOF > gzip || fail=1
+#!$SHELL
 tr 41 14
 touch ok
 EOF
index 054c5aec66f237c09b2b04f82f22de1b76a1f8d0..d47f0dc83d28d8be7ff37c8b443bacc7dbd6b4cc 100755 (executable)
@@ -30,8 +30,8 @@ print_ver_ timeout
 
 setsid true || skip_ "setsid required to control groups"
 
-cat > timeout.cmd <<\EOF
-#!/bin/sh
+printf '%s\n' '#!'"$SHELL" > timeout.cmd || framework_failure_
+cat >> timeout.cmd <<\EOF
 trap 'touch int.received; exit' INT
 touch timeout.running
 count=$1
@@ -42,8 +42,8 @@ done
 EOF
 chmod a+x timeout.cmd
 
-cat > group.sh <<\EOF
-#!/bin/sh
+cat > group.sh <<EOF
+#!$SHELL
 trap '' INT
 timeout --foreground 25 ./timeout.cmd 20&
 wait
index 80299b4d4b6a6ea7f99e5c4144fa3f348d0127c3..7a5b9ce15bb3a038148316169467225de4b7a8f4 100755 (executable)
@@ -32,7 +32,6 @@ my $verbose = $ENV{VERBOSE} && $ENV{VERBOSE} eq 'yes';
 $ENV{LC_ALL} = 'C';
 
 # Set up a safe, well-known environment
-delete @ENV{qw(BASH_ENV CDPATH ENV)};
 $ENV{IFS}  = '';
 
 # Taint checking requires a sanitized $PATH.  This script performs no $PATH