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

Re: cd, pwd and symlinks

Verily did "Stefan Monnier" write:

>>> youkaidi ~ % mkdir foo
>>> youkaidi ~ % mkdir foo/bar
>>> youkaidi ~ % md bar
>>> youkaidi ~ % cd bar
>>> youkaidi ~/bar % ln -s ../foo/bar foo
>>> youkaidi ~/bar % cd foo
>>> youkaidi ~/bar/foo % ls ..
>>> bar
*>> youkaidi ~/bar/foo % pwd
*>> /udd/canon/foo/bar
*>> youkaidi ~/bar/foo % /bin/pwd
*>> /udd/canon/foo/bar
*>> youkaidi ~/bar/foo % cd ..
*>> youkaidi ~/bar % 

>> Put `setopt chaselinks' or `setopt chasedots' in your .zshrc.  From
>> the info pages:

> I must say I don't like the names and defaults.  The names give the
> impression that chasing links is a very unusual feature while it's the
> normal unix behavior.

That depends wholly upon the shell.  C-shell variants do it one way, sh
sorta does it like zsh (the items marked with a `*' above are like csh,
but because sh doesn't appear to have a builtin cd(1) or pwd(1)).  Zsh
does it (by default?) the same way that ksh does.

The use of symlinks pointing to subdirs has long been flagged as A Bad
Idea due to the handling of `..', so "ymmv" when you choose to use them.

> But apart from that, I'm more often annoyed by `pwd' not checking the
> value it returns:

> 	~/tmp-0% mkdir foo 
> 	~/tmp-0% cd foo
> 	tmp/foo-0% mv ../foo ../bar
> 	tmp/foo-0% pwd
> 	/home/monnier/tmp/foo
> 	tmp/foo-0% 

> This is with 3.0.6,

And ksh does the same thing.  Again, sh(1) doesn't do this because it
doesn't have a builtin pwd(1).

I'm surely not complaining about how zsh handles either of these behaviors,
I prefer a ksh-on-steriods look and smell for a shell.

-- Rob
Internet: windsor@xxxxxxxxxxx                             __o
Life: Rob@xxxxxxxxxxxxxxxxxxxxxxxxxx                    _`\<,_
                                                       (_)/ (_)
The weather is here, wish you were beautiful.

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