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

Re: FW: Full path with ksh emulation



"Tony Hasler" wrote:
> The bad news is that it didn't work.  It tries to find the argument in
> $PATH, but when "." isn't there it reverts to the builtin.  When "." is in
> the path you get an absolute path, but one with a "." in it.  Only when the
> absolute path of "." is in $PATH and is the first place with an executable
> copy of the script does it seem to work.

Ah.  You're right.

>   if [[ $(builtin whence $1) == .* ]]; then

That looks good enough.  You can optimise out the subprocess by changing
this to

   if [[ $1 == .* || $(builtin whence $1) == .* ]]; then

the point being that in your case, where . isn't part of the path, you
are actually relying on the . being part of $1, so you never need the
code in the $(...).

You could probably change the patterns to (.|..)/* (as we're in
zsh-specific land) for a little extra safety but it doesn't make much
difference unless you have files starting with ".".

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


Your mail client is unable to display the latest news from CSR. To access our news copy this link into a web browser:  http://www.csr.com/email_sig.html



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