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

Re: PATCH: cd -q (was Re: _canonical_path ...)



On Thu, Mar 27, 2008 at 12:15:25PM +0000, Peter Stephenson wrote:
> On Thu, 27 Mar 2008 11:25:06 +0000
> Peter Stephenson <pws@xxxxxxx> wrote:
> > I thought unfunction was silent if a function didn't exist, as is now
> > true of (and required for) unset, but apparently not.
> > +_canonical_paths_pwd() {
> > +  # Get the canonical directory name by changing to it.
> > +  # To be run in a subshell.
> > +  (( ${+functions[chpwd]} )) && unfunction chpwd
> > +  setopt CHASE_LINKS
> > +  cd $1 2>/dev/null && pwd
> > +}
[...]

You need cd -- "$1"
you might also want cd -P.

With "emulate sh", cd -P -- "$1" && pwd -P should return an
absolute path.

-- 
Stéphane



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