DASH Shell discussions
 help / color / mirror / Atom feed
* bugs in cd
@ 2009-07-14 21:39 Eric Blake
  2009-08-31 11:28 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Eric Blake @ 2009-07-14 21:39 UTC (permalink / raw)
  To: dash

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



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-09-18  0:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-14 21:39 bugs in cd Eric Blake
2009-08-31 11:28 ` Eric Blake
2009-08-31 12:07 ` Herbert Xu
2009-08-31 12:18 ` Herbert Xu
2009-08-31 12:23   ` Eric Blake
2009-08-31 12:56     ` Herbert Xu
2009-08-31 14:08       ` Eric Blake
2009-09-18  0:03         ` Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox