1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 03:32:24 +00:00

Fix 'cd -e' regress fails on some UNIXen (re: e6989853, b398f33c)

On some systems, including at least Solaris 10.1 and QNX 6.5.0, the
regression tests below occurred. This is because, on these systems,
'cd .' always fails with 'no such file or directory', regardless of
flags, if the present working directory no longer exists. This is a
legitimate variation in UNIX-like systems so the tests should be
compatible.

test builtins begins at 2022-05-22+13:08:28
/usr/local/src/ksh/src/cmd/ksh93/tests/builtins.sh[1499]: cd: .: [No such file or directory]
        builtins.sh[1501]: FAIL: cd -P without -e exits with error status if $PWD doesn't exist (expected 0, got 1)
/usr/local/src/ksh/src/cmd/ksh93/tests/builtins.sh[1504]: cd: .: [No such file or directory]
        builtins.sh[1506]: FAIL: cd -eP doesn't fail if $PWD doesn't exist (expected 1, got 2)
test builtins failed at 2022-05-22+13:08:37 with exit code 2 [ 287 tests 2 errors ]

src/cmd/ksh93/tests/builtins.sh:
- Delete the 'cd -P .' test for a nonexistent PWD.
- For the 'cd -eP .' test for a nonexistent PWD, redirect standard
  error to /dev/null and also accept exit status 2, which we would
  expect with the '-e' flag if a 'no such file or directory' error
  is thrown.
This commit is contained in:
Martijn Dekker 2022-05-22 12:36:58 +01:00
parent 2b27f63d64
commit c2fad38bf8

View file

@ -1493,17 +1493,12 @@ fi
# ======
# These are regression tests for the cd command's -e and -P flags
mkdir -p "$tmp/failpwd"
cd "$tmp/failpwd"
"$SHELL" -c 'cd /; exec rmdir "$1"' x "$tmp/failpwd"
cd -P .
got=$?; exp=0
(( got == exp )) || err_exit "cd -P without -e exits with error status if \$PWD doesn't exist (expected $exp, got $got)"
if ((.sh.version >= 20211205))
then
cd -eP .
got=$?; exp=1
(( got == exp )) || err_exit "cd -eP doesn't fail if \$PWD doesn't exist (expected $exp, got $got)"
mkdir -p "$tmp/failpwd"
cd "$tmp/failpwd"
"$SHELL" -c 'cd /; exec rmdir "$1"' x "$tmp/failpwd"
cd -eP . 2>/dev/null && err_exit "cd -eP doesn't fail if \$PWD doesn't exist"
fi
cd "$tmp"