- Subject: bugs in cd
- From: Eric Blake <ebb9@xxxxxxx>
- Date: Tue, 14 Jul 2009 21:39:03 +0000 (UTC)
- User-agent: Loom/3.14 (http://gmane.org/)
For the cd command, POSIX 2008 requires that after all pathnames in CDPATH have
been tested and failed in step 5, then step 6 interprets the directory argument
relative to PWD. In other words, this demonstrates a bug:
$ dash -c 'cd /tmp; mkdir -p foo; CDPATH=oops; cd foo; echo $?; pwd'
cd: 1: can't cd to foo
2
/tmp
while bash gets it correct:
$ bash -c 'cd /tmp; mkdir -p foo; CDPATH=oops; cd foo; echo $?; pwd'
0
/tmp/foo
Furthermore, POSIX requires that if the element in CDPATH ends in slash, that
no additional slashes are added while forming the candidate curpath. In light
of the fact that //home need not be the same directory as /home (and indeed, on
cygwin, they are distinct entities), this is also a bug:
$ dash -c 'CDPATH=/; cd home'
//home
$ bash -c 'CDPATH=/; cd home'
/home
--
Eric Blake
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[LARTC]
[Bugtraq]
[Yosemite Forum]
[Photo]