export __progname as environment to the test script,

so that the "$0" abuse can stop
This commit is contained in:
tg 2008-04-01 16:01:45 +00:00
parent 506326f051
commit 018d44cf4c
2 changed files with 33 additions and 28 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.pl,v 1.15 2008/03/23 20:54:29 tg Exp $ # $MirOS: src/bin/mksh/check.pl,v 1.16 2008/04/01 16:01:45 tg Exp $
# $OpenBSD: th,v 1.12 2005/05/28 04:53:47 millert Exp $ # $OpenBSD: th,v 1.12 2005/05/28 04:53:47 millert Exp $
#- #-
# Example test: # Example test:
@ -57,6 +57,7 @@
# (values taken from the environment of # (values taken from the environment of
# the test harness). # the test harness).
# ENV is set to /nonexistant. # ENV is set to /nonexistant.
# __progname is set to the -p argument.
# file-setup mps Used to create files, directories # file-setup mps Used to create files, directories
# and symlinks. First word is either # and symlinks. First word is either
# file, dir or symlink; second word is # file, dir or symlink; second word is
@ -493,6 +494,10 @@ run_test
} }
push(@argv, $temps) if defined $test{'script'}; push(@argv, $temps) if defined $test{'script'};
#XXX realpathise, use which/whence -p, or sth. like that
#XXX if !$program_kludge, we get by with not doing it for now tho
$new_env{'__progname'} = $argv[0];
# The following doesn't work with perl5... Need to do it explicitly - yuck. # The following doesn't work with perl5... Need to do it explicitly - yuck.
#%ENV = %new_env; #%ENV = %new_env;
foreach $k (keys(%ENV)) { foreach $k (keys(%ENV)) {

54
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.163 2008/03/28 13:46:51 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.164 2008/04/01 16:01:45 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -1454,7 +1454,7 @@ stdin:
bar="bar bar="bar
baz" baz"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
$0 -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo" $__progname -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar" tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar' tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
@ -3375,7 +3375,7 @@ description:
Check that (here doc) temp files are not left behind after an exec. Check that (here doc) temp files are not left behind after an exec.
stdin: stdin:
mkdir foo || exit 1 mkdir foo || exit 1
TMPDIR=$PWD/foo "$0" <<- 'EOF' TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
x() { x() {
sed 's/^/X /' << E_O_F sed 's/^/X /' << E_O_F
hi hi
@ -3388,7 +3388,7 @@ stdin:
exec $echo subtest-1 hi exec $echo subtest-1 hi
EOF EOF
echo subtest-1 foo/* echo subtest-1 foo/*
TMPDIR=$PWD/foo "$0" <<- 'EOF' TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
echo=echo; [ -x /bin/echo ] && echo=/bin/echo echo=echo; [ -x /bin/echo ] && echo=/bin/echo
sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
a a
@ -4150,9 +4150,9 @@ name: pipeline-2
description: description:
check that co-processes work with TCOMs, TPIPEs and TPARENs check that co-processes work with TCOMs, TPIPEs and TPARENs
stdin: stdin:
"$0" -c 'i=100; print hi |& while read -p line; do print "$((i++)) $line"; done' "$__progname" -c 'i=100; print hi |& while read -p line; do print "$((i++)) $line"; done'
"$0" -c 'i=200; print hi | cat |& while read -p line; do print "$((i++)) $line"; done' "$__progname" -c 'i=200; print hi | cat |& while read -p line; do print "$((i++)) $line"; done'
"$0" -c 'i=300; (print hi | cat) |& while read -p line; do print "$((i++)) $line"; done' "$__progname" -c 'i=300; (print hi | cat) |& while read -p line; do print "$((i++)) $line"; done'
expected-stdout: expected-stdout:
100 hi 100 hi
200 hi 200 hi
@ -4203,12 +4203,12 @@ stdin:
print got ${#anzahl[*]} files print got ${#anzahl[*]} files
chmod +x foo/* chmod +x foo/*
export PATH=$(pwd)/foo:$PATH export PATH=$(pwd)/foo:$PATH
"$0" -c 'fnord' "$__progname" -c 'fnord'
"$0" -c 'fnord; fnord; fnord; fnord' "$__progname" -c 'fnord; fnord; fnord; fnord'
"$0" foo/bar "$__progname" foo/bar
"$0" <foo/bar "$__progname" <foo/bar
"$0" foo/zoo "$__progname" foo/zoo
"$0" -c 'print : $(fnord)' "$__progname" -c 'print : $(fnord)'
rm -rf foo rm -rf foo
expected-stdout: expected-stdout:
got 4 files got 4 files
@ -4241,8 +4241,8 @@ description:
category: pdksh,!os:cygwin,!os:uwin-nt category: pdksh,!os:cygwin,!os:uwin-nt
env-setup: !FOO=BAR! env-setup: !FOO=BAR!
stdin: stdin:
print '#!'"$0"'\nprint "a=$ENV{FOO}";' >t1 print '#!'"$__progname"'\nprint "a=$ENV{FOO}";' >t1
print '#!'"$0"'\nprint "a=$ENV{FOO}";' >t2 print '#!'"$__progname"'\nprint "a=$ENV{FOO}";' >t2
print '#!/usr/bin/env perl\nprint "a=$ENV{FOO}\n";' >t3 print '#!/usr/bin/env perl\nprint "a=$ENV{FOO}\n";' >t3
print '#!/usr/bin/env perl\nprint "a=$ENV{FOO}\n";' >t4 print '#!/usr/bin/env perl\nprint "a=$ENV{FOO}\n";' >t4
chmod +x t? chmod +x t?
@ -4261,8 +4261,8 @@ description:
Reading the UTF-8 BOM should enable the utf8-hack flag Reading the UTF-8 BOM should enable the utf8-hack flag
category: pdksh,!dutf category: pdksh,!dutf
stdin: stdin:
"$0" -c ':; x=$(set +o); if [[ $x = *utf8* ]]; then print on; else print off; fi' "$__progname" -c ':; x=$(set +o); if [[ $x = *utf8* ]]; then print on; else print off; fi'
"$0" -c ':; x=$(set +o); if [[ $x = *utf8* ]]; then print on; else print off; fi' "$__progname" -c ':; x=$(set +o); if [[ $x = *utf8* ]]; then print on; else print off; fi'
expected-stdout: expected-stdout:
off off
on on
@ -4309,7 +4309,7 @@ description:
category: disabled category: disabled
arguments: !-o!posix! arguments: !-o!posix!
stdin: stdin:
cp "$0" sh cp "$__progname" sh
./sh -c 'alias; typeset -f' ./sh -c 'alias; typeset -f'
rm -f sh rm -f sh
expected-stdout: expected-stdout:
@ -4345,7 +4345,7 @@ description:
category: pdksh category: pdksh
arguments: !-o!posix! arguments: !-o!posix!
stdin: stdin:
cp "$0" sh cp "$__progname" sh
./sh -c 'alias; typeset -f' ./sh -c 'alias; typeset -f'
rm -f sh rm -f sh
expected-stdout: expected-stdout:
@ -4446,12 +4446,12 @@ description:
This is by design. And that some things fail in both. This is by design. And that some things fail in both.
stdin: stdin:
export x=abcdefghi n=2 export x=abcdefghi n=2
"$0" -c 'print v${x:(n)}x' "$__progname" -c 'print v${x:(n)}x'
"$0" -c 'print w${x: n}x' "$__progname" -c 'print w${x: n}x'
"$0" -c 'print x${x:n}x' "$__progname" -c 'print x${x:n}x'
"$0" -c 'print y${x:}x' "$__progname" -c 'print y${x:}x'
"$0" -c 'print z${x}x' "$__progname" -c 'print z${x}x'
"$0" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; print $? "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; print $?
expected-stdout: expected-stdout:
vcdefghix vcdefghix
wcdefghix wcdefghix
@ -4482,8 +4482,8 @@ name: dot-needs-argument
description: description:
check Debian #415167 solution: '.' without arguments should fail check Debian #415167 solution: '.' without arguments should fail
stdin: stdin:
"$0" -c . "$__progname" -c .
"$0" -c source "$__progname" -c source
expected-exit: e != 0 expected-exit: e != 0
expected-stderr-pattern: expected-stderr-pattern:
/\.: missing argument.*\n.*\.: missing argument/ /\.: missing argument.*\n.*\.: missing argument/