diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-07-03 04:44:05 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-07-03 13:02:21 +0100 |
commit | 1d4289b3c10f5d8002fd59a518fbb7b148794449 (patch) | |
tree | 2017d1fd33f5c92a9beb44dab5fdda5fb19f0813 /tests/misc | |
parent | 970b89170206779e028fce6a28f0924c7e47bfd1 (diff) | |
download | coreutils-1d4289b3c10f5d8002fd59a518fbb7b148794449.tar.xz |
tests: avoid side effects of $SHELL environment variable
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.
Diffstat (limited to 'tests/misc')
-rwxr-xr-x | tests/misc/help-version.sh | 6 | ||||
-rwxr-xr-x | tests/misc/pwd-long.sh | 1 | ||||
-rwxr-xr-x | tests/misc/sort-compress-hang.sh | 4 | ||||
-rwxr-xr-x | tests/misc/sort-compress-proc.sh | 5 | ||||
-rwxr-xr-x | tests/misc/sort-compress.sh | 4 | ||||
-rwxr-xr-x | tests/misc/timeout-group.sh | 8 |
6 files changed, 11 insertions, 17 deletions
diff --git a/tests/misc/help-version.sh b/tests/misc/help-version.sh index e0dd721f9..78150374d 100755 --- a/tests/misc/help-version.sh +++ b/tests/misc/help-version.sh @@ -17,12 +17,6 @@ # 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 diff --git a/tests/misc/pwd-long.sh b/tests/misc/pwd-long.sh index 927fdcff2..3ced777ae 100755 --- a/tests/misc/pwd-long.sh +++ b/tests/misc/pwd-long.sh @@ -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 diff --git a/tests/misc/sort-compress-hang.sh b/tests/misc/sort-compress-hang.sh index 9cfd6cc90..dc101fea8 100755 --- a/tests/misc/sort-compress-hang.sh +++ b/tests/misc/sort-compress-hang.sh @@ -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 diff --git a/tests/misc/sort-compress-proc.sh b/tests/misc/sort-compress-proc.sh index 4ad42d514..05017a54f 100755 --- a/tests/misc/sort-compress-proc.sh +++ b/tests/misc/sort-compress-proc.sh @@ -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" diff --git a/tests/misc/sort-compress.sh b/tests/misc/sort-compress.sh index 605d539ba..584110e12 100755 --- a/tests/misc/sort-compress.sh +++ b/tests/misc/sort-compress.sh @@ -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 diff --git a/tests/misc/timeout-group.sh b/tests/misc/timeout-group.sh index 054c5aec6..d47f0dc83 100755 --- a/tests/misc/timeout-group.sh +++ b/tests/misc/timeout-group.sh @@ -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 |