Skip to content

Commit 39d1c64

Browse files
committed
fix regression tests (re: e57af0e, f7ffaab, d148315)
1 parent e57af0e commit 39d1c64

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/cmd/ksh93/tests/builtins.sh

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -953,62 +953,62 @@ done
953953
# ======
954954
# 'cd ../.foo' should not exclude the '.' in '.foo'
955955
# https://bugzilla.redhat.com/889748
956-
expect=$tmp/.ssh
957-
actual=$( HOME=$tmp
956+
exp=$tmp/.ssh
957+
got=$( HOME=$tmp
958958
mkdir ~/.ssh 2>&1 &&
959959
cd ~/.ssh 2>&1 &&
960960
cd ../.ssh 2>&1 &&
961961
print -r -- "$PWD" )
962-
[[ $actual == "$expect" ]] || err_exit 'changing to a hidden directory using a path that contains the parent directory (..) fails' \
963-
"(expected $(printf %q "$expect"), got $(printf %q "$actual"))"
964-
expect=$tmp/.java
965-
actual=$( mkdir "$tmp/java" "$tmp/.java" 2>&1 &&
962+
[[ $got == "$exp" ]] || err_exit 'changing to a hidden directory using a path that contains the parent directory (..) fails' \
963+
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
964+
exp=$tmp/.java
965+
got=$( mkdir "$tmp/java" "$tmp/.java" 2>&1 &&
966966
cd "$tmp/.java" 2>&1 &&
967967
cd ../.java 2>&1 &&
968968
pwd )
969-
[[ $actual == "$expect" ]] || err_exit 'the dot (.) part of the directory name is being stripped' \
970-
"(expected $(printf %q "$expect"), got $(printf %q "$actual"))"
969+
[[ $got == "$exp" ]] || err_exit 'the dot (.) part of the directory name is being stripped' \
970+
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
971971
972972
# check that we cannot cd into a regular file and get misbehaviour
973973
: > "$tmp/regular_file"
974-
expect=": cd: $tmp/regular_file: [Not a directory]"
975-
actual=$(LC_ALL=C cd "$tmp/regular_file" 2>&1)
974+
exp=": cd: $tmp/regular_file: \\[?Not a directory]?$"
975+
got=$(LC_ALL=C cd "$tmp/regular_file" 2>&1)
976976
e=$?
977-
[[ e -eq 1 && $actual == *"$expect" ]] || err_exit 'can cd into a regular file' \
978-
"(expected status 1 and msg ending in $(printf %q "$expect"), got status $e and msg $(printf %q "$actual"))"
977+
[[ e -eq 1 && $got =~ $exp ]] || err_exit 'can cd into a regular file' \
978+
"(expected status 1 and match of $(printf %q "$exp"), got status $e and $(printf %q "$got"))"
979979
980980
# https://bugzilla.redhat.com/1102627
981981
if [[ $(id -u) == '0' ]]
982982
then warning "running as root: skipping tests involving directory search (x) permission"
983983
else
984984
mkdir -m 600 "$tmp/no_x_dir"
985-
expect=": cd: $tmp/no_x_dir: [Permission denied]"
986-
actual=$(LC_ALL=C cd "$tmp/no_x_dir" 2>&1)
985+
exp=": cd: $tmp/no_x_dir: \\[?Permission denied]?$"
986+
got=$(LC_ALL=C cd "$tmp/no_x_dir" 2>&1)
987987
e=$?
988-
[[ e -eq 1 && $actual == *"$expect" ]] || err_exit 'can cd into a directory without x permission bit (absolute path arg)' \
989-
"(expected status 1 and msg ending in $(printf %q "$expect"), got status $e and msg $(printf %q "$actual"))"
990-
expect=": cd: no_x_dir: [Permission denied]"
991-
actual=$(cd "$tmp" 2>&1 && LC_ALL=C cd "no_x_dir" 2>&1)
988+
[[ e -eq 1 && $got =~ $exp ]] || err_exit 'can cd into a directory without x permission bit (absolute path arg)' \
989+
"(expected status 1 and match of $(printf %q "$exp"), got status $e and $(printf %q "$got"))"
990+
exp=": cd: no_x_dir: \\[?Permission denied]?$"
991+
got=$(cd "$tmp" 2>&1 && LC_ALL=C cd "no_x_dir" 2>&1)
992992
e=$?
993-
[[ e -eq 1 && $actual == *"$expect" ]] || err_exit 'can cd into a directory without x permission bit (relative path arg)' \
994-
"(expected status 1 and msg ending in $(printf %q "$expect"), got status $e and msg $(printf %q "$actual"))"
993+
[[ e -eq 1 && $got =~ $exp ]] || err_exit 'can cd into a directory without x permission bit (relative path arg)' \
994+
"(expected status 1 and match of $(printf %q "$exp"), got status $e and $(printf %q "$got"))"
995995
rmdir "$tmp/no_x_dir" # on HP-UX, 'rm -rf $tmp' won't work unless we rmdir this or fix the perms
996996
fi
997997
998998
# https://bugzilla.redhat.com/1133582
999-
expect=$HOME
1000-
actual=$({ a=`cd; pwd`; } >&-; print -r -- "$a")
1001-
[[ $actual == "$expect" ]] || err_exit "'cd' broke old-form command substitution with outer stdout closed" \
1002-
"(expected $(printf %q "$expect"), got $(printf %q "$actual"))"
1003-
actual=$({ a=$(cd; pwd); } >&-; print -r -- "$a")
1004-
[[ $actual == "$expect" ]] || err_exit "'cd' broke new-form command substitution with outer stdout closed" \
1005-
"(expected $(printf %q "$expect"), got $(printf %q "$actual"))"
999+
exp=$HOME
1000+
got=$({ a=`cd; pwd`; } >&-; print -r -- "$a")
1001+
[[ $got == "$exp" ]] || err_exit "'cd' broke old-form command substitution with outer stdout closed" \
1002+
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
1003+
got=$({ a=$(cd; pwd); } >&-; print -r -- "$a")
1004+
[[ $got == "$exp" ]] || err_exit "'cd' broke new-form command substitution with outer stdout closed" \
1005+
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
10061006
10071007
# CDPATH was not ignored by 'cd ./dir': https://github.com/ksh93/ksh/issues/151
1008-
expect=': cd: ./dev: [No such file or directory]'
1009-
actual=$( (CDPATH=/ LC_ALL=C cd -P ./dev && pwd) 2>&1 )
1010-
let "(e=$?)==1" && [[ $actual == *"$expect" ]] || err_exit "CDPATH not ignored by cd ./dir" \
1011-
"(expected *$(printf %q "$expect") with status 1, got $(printf %q "$actual") with status $e)"
1008+
exp=': cd: ./dev: \[?No such file or directory]?$'
1009+
got=$( (CDPATH=/ LC_ALL=C cd -P ./dev && pwd) 2>&1 )
1010+
let "(e=$?)==1" && [[ $got =~ $exp ]] || err_exit "CDPATH not ignored by cd ./dir" \
1011+
"(expected status 1 and match of $(printf %q "$exp"), got status $e and $(printf %q "$got"))"
10121012
10131013
# ======
10141014
# 'readonly' should set the correct scope when creating variables in functions

0 commit comments

Comments
 (0)