Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: cd bugs



Eric Blake <ebb9 <at> byu.net> writes:

> 
> POSIX requires cd to give output if a nonempty entry in CDPATH played a role,
> or if 'cd -' was used.  Therefore, this line demonstrates two zsh bugs:
> 
> $ zsh -c 'emulate -R sh; cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d'
> $ bash -c 'cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d'
> /tmp/d
> /tmp
> $
> 
> while bash was correct in printing the absolute name of d and its parent.

Another bug - POSIX requires that CDPATH be searched prior to ., regardless of
whether CDPATH contains an explicit . or an empty entry.  Therefore, this is
another example where bash is right.  But I think the zsh native behavior of
favoring . over CDPATH if CDPATH does not include . is a little more intuitive,
so this may warrant the addition of a new shell option (POSIX_CD?) that defaults
to off in zsh mode but defaults to on in sh mode for POSIX compliance.

$ zsh -c 'emulate -R sh; cd /tmp; mkdir -p a/b b; CDPATH=a; cd b; /bin/pwd'
/tmp/b
$ bash -c 'cd /tmp; mkdir -p a/b b; CDPATH=a; cd b; /bin/pwd'
/tmp/a/b
/tmp/a/b
$ cd /tmp; rm -Rf a b
$

-- 
Eric Blake




Messages sorted by: Reverse Date, Date, Thread, Author