mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
'cd': properly ignore $CDPATH if initial component is '.' or '..'
@stephane-chazelas writes: > Per POSIX[*], cd should skip the $CDPATH processing if the first > component of the directory given to cd is . or ... > > Yet, with ksh93u+m 2021-01-03 at least, while that's OK with .., > it's not with . with or without the posix option: > > $ CDPATH=/ ./ksh -o posix -c 'cd -P ./etc && pwd' > /etc > /etc > > It seems to be a regression introduced with ksh93u+ as I can't > reproduce it with ksh93u or any version prior to that. I can also > reproduce in u+, v- and the ksh2020 from the Ubuntu 20.04 > package. src/cmd/ksh93/bltins/cd_pwd.c: b_cd(): - Skip $CDPATH processing not only if the path is absolute, but also if the initial path component is '.' or '..' (in the latter case the $CDPATH processing was done but appeared to be a no-op). src/cmd/ksh93/tests/builtins.sh: - Add regression test. [*] https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/cd.html Fixes: https://github.com/ksh93/ksh/issues/151
This commit is contained in:
parent
3567220898
commit
d1483150ab
4 changed files with 18 additions and 4 deletions
|
@ -832,6 +832,12 @@ actual=$({ a=$(cd; pwd); } >&-; print -r -- "$a")
|
|||
[[ $actual == "$expect" ]] || err_exit "'cd' broke new-form command substitution with outer stdout closed" \
|
||||
"(expected $(printf %q "$expect"), got $(printf %q "$actual"))"
|
||||
|
||||
# CDPATH was not ignored by 'cd ./dir': https://github.com/ksh93/ksh/issues/151
|
||||
expect=': cd: ./dev: [No such file or directory]'
|
||||
actual=$( (CDPATH=/ cd -P ./dev && pwd) 2>&1 )
|
||||
let "(e=$?)==1" && [[ $actual == *"$expect" ]] || err_exit "CDPATH not ignored by cd ./dir" \
|
||||
"(expected *$(printf %q "$expect") with status 1, got $(printf %q "$actual") with status $e)"
|
||||
|
||||
# ======
|
||||
# 'readonly' should set the correct scope when creating variables in functions
|
||||
unset foo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue