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

Re: Directory completion acts as if CHASE_LINKS is set



On Sep 6,  9:09pm, Peter Stephenson wrote:
} Subject: Re: Directory completion acts as if CHASE_LINKS is set
}
} On Thu, 05 Sep 2013 08:31:39 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > +    # Use cd in a subshell to properly [not] resolve symlinks
} > +    tmpprefix=$(cd $PREFIX >&/dev/null && print $PWD) ||
} > +      tmpprefix=$(cd $PREFIX:h >&/dev/null && print $PWD/$PREFIX:t)
} 
} You're probably going to be better off using ${PREFIX:a} rather than
} cd.

No, sorry, that doesn't work; :a behaves like globbing and CHASE_DOTS:

torch% print $PWD
/tmp/cdtest/foo/bar
torch% x=..        
torch% print $x:a
/tmp/cdtest

As far as I can tell the only way to get symlinks resolved the way that
"cd" does with respect to whatever CHASE options are currently set, is
to actually perform the "cd".

} I also wonder if it would be better only to look at previous
} directory components, i.e. always take the PREFIX up to the last "/"
} (and require that there be one) rather than have two cases.

You'll have to actually write out what you mean here, because I can't
get it to work for e.g. "cd ../" without having the first case there.

} I doubt there's much you can do better if you're completing in the
} middle of the word.

Indeed.  Also things may be a bit strange when a cdablevar is at the
front of the path, with a /../ somewhere beyond it.

Any suggestions for how to avoid having "../" expand into $PWD:h/ on
the command line?  I tried fiddling with IPREFIX the way the cdablevars
branch does, but without success.



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