bugs in cd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux