@@ -953,62 +953,62 @@ done
953
953
# ======
954
954
# 'cd ../.foo' should not exclude the '.' in '.foo'
955
955
# https://bugzilla.redhat.com/889748
956
- expect =$tmp /.ssh
957
- actual =$( HOME=$tmp
956
+ exp =$tmp /.ssh
957
+ got =$( HOME=$tmp
958
958
mkdir ~ /.ssh 2>&1 &&
959
959
cd ~ /.ssh 2>&1 &&
960
960
cd ../.ssh 2>&1 &&
961
961
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 &&
966
966
cd " $tmp /.java" 2>&1 &&
967
967
cd ../.java 2>&1 &&
968
968
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 " ) )"
971
971
972
972
# check that we cannot cd into a regular file and get misbehaviour
973
973
: > " $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 )
976
976
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 " ) )"
979
979
980
980
# https://bugzilla.redhat.com/1102627
981
981
if [[ $( id -u) == ' 0' ]]
982
982
then warning " running as root: skipping tests involving directory search (x) permission"
983
983
else
984
984
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 )
987
987
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 )
992
992
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 " ) )"
995
995
rmdir " $tmp /no_x_dir" # on HP-UX, 'rm -rf $tmp' won't work unless we rmdir this or fix the perms
996
996
fi
997
997
998
998
# 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 " ) )"
1006
1006
1007
1007
# 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 " ) )"
1012
1012
1013
1013
# ======
1014
1014
# 'readonly' should set the correct scope when creating variables in functions
0 commit comments