zsh-workers
 help / color / mirror / code / Atom feed
* ZSH - tab-completion of $PATH won't work with /./ or /../ in it
@ 2015-12-09  5:24 John Polansky
  2015-12-09  6:22 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: John Polansky @ 2015-12-09  5:24 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 722 bytes --]

I've noticed a bug in:

 zsh --version
zsh 5.2 (x86_64-apple-darwin15.0.0)

It drove me up the wall before I realized but it appears if in your $PATH
variable you have a path that contains /./ or /../ the tab-completion for
commands will not search that directory.

For example

*export PATH=/Users/jpolansky/test*
which has a command *cmd_test* in it with +x permissions.

$ cmd<tab>
-- it finds cmd_test

But if you have:
*export PATH=/Users/jpolansky/./test*
*or*
*export PATH=/Users/jpolansky/../test*

*#cmd<tab>*
-- fails to find cmd_test

While I realize it's unusual to have . or .. in a path.. it can happen
through scripting and to me this seems like a bug which should be fixed.
Hopefully you will agree.

John

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ZSH - tab-completion of $PATH won't work with /./ or /../ in it
  2015-12-09  5:24 ZSH - tab-completion of $PATH won't work with /./ or /../ in it John Polansky
@ 2015-12-09  6:22 ` Bart Schaefer
  2015-12-09 10:00   ` Peter Stephenson
  2015-12-09 11:50   ` Peter Stephenson
  0 siblings, 2 replies; 4+ messages in thread
From: Bart Schaefer @ 2015-12-09  6:22 UTC (permalink / raw)
  To: Zsh hackers list

On Tue, Dec 8, 2015 at 9:24 PM, John Polansky <johnpolansky@gmail.com> wrote:
>
> While I realize it's unusual to have . or .. in a path.. it can happen
> through scripting and to me this seems like a bug which should be fixed.

As is often the case, this is not as obvious as it may appear.

Command completion uses the command hash table.  Commands that appear
in the hash table are, pretty much by definition, the commands that
are completed.  There is no actual path search during completion, just
a hash table lookup.

The command hash table has NEVER included commands that appear along
any relative path.

So the behavior you are describing is technically not a bug; it's
standard zsh behavior for the last 20 or so years.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ZSH - tab-completion of $PATH won't work with /./ or /../ in it
  2015-12-09  6:22 ` Bart Schaefer
@ 2015-12-09 10:00   ` Peter Stephenson
  2015-12-09 11:50   ` Peter Stephenson
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2015-12-09 10:00 UTC (permalink / raw)
  To: Zsh hackers list

On Tue, 08 Dec 2015 22:22:36 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Tue, Dec 8, 2015 at 9:24 PM, John Polansky <johnpolansky@gmail.com> wrote:
> >
> > While I realize it's unusual to have . or .. in a path.. it can happen
> > through scripting and to me this seems like a bug which should be fixed.
> 
> The command hash table has NEVER included commands that appear along
> any relative path.

You can rationalise your path simply enough in one of your start-up
files:

path=(${path:a})

pws


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ZSH - tab-completion of $PATH won't work with /./ or /../ in it
  2015-12-09  6:22 ` Bart Schaefer
  2015-12-09 10:00   ` Peter Stephenson
@ 2015-12-09 11:50   ` Peter Stephenson
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2015-12-09 11:50 UTC (permalink / raw)
  To: Zsh hackers list

On Tue, 08 Dec 2015 22:22:36 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> The command hash table has NEVER included commands that appear along
> any relative path.

...and actually, this can't be the problem.  The path isn't relative, it
just a ".." or "." in it(e.g. /Users/jpolansky/./test), and this usually
works...

$path contains just normal path:

% which config.status
config.status not found

$path also contains /export/home/pws/src/zsh-git/code/Src/..:

% which config.status
/export/home/pws/src/zsh-git/code/Src/..

and config.status is completed.

Same with
/export/home/pws/src/zsh-git/code/./

So something else is going on.

pws


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-09 11:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-09  5:24 ZSH - tab-completion of $PATH won't work with /./ or /../ in it John Polansky
2015-12-09  6:22 ` Bart Schaefer
2015-12-09 10:00   ` Peter Stephenson
2015-12-09 11:50   ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).