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

Re: Can't tell the difference in operation between PATH_SCRIPT and NO_PATH_SCRIPT



Sorry, I’ve got a bad misconcepiton somewhere. I stil don’t get it.

I do: PATH=.dir

When I do: setopt pathscript
And then do: foo.zsh

It finds foo in the ./dir directory and executes it.


Then when i do: unsetopt pathscript
And then I do: foo.zsh

It stil finds foo.zsh in the ./dir directory.

So I’m not seeing how it behaves any differently. 





On Jan 25, 2024, at 10:05 PM, Lawrence Velázquez <larryv@xxxxxxx> wrote:

On Thu, Jan 25, 2024, at 9:00 PM, Steve Dondley wrote:
I’ve been looking over the documentation and I really can’t make sense
out of what the PATH_SCRIPT option is supposed to do.

If it’s set, which it is by default, I think it’s supposed to look
through directories PATH and try to find the command. But if it’s not
set, it doesn’t look through directories in PATH.

At least that’s my understanding. But as a far as I can tell, I can run
a command in /bin with or without PATH_SCRIPT option set.

I’m obviously confused about what the docs are saying. Can someone shed
light on this for me?

The option affects how zsh behaves when invoked without -c or -s
and with a first non-option argument that doesn't contain any
slashes.  In this situation, shells generally try to find and run
a script with that name in the current directory; if there is no
such script, they try to find one in PATH.  PATH_SCRIPT lets you
control whether zsh performs that fallback PATH search.  (It does
not affect other PATH searches.)

% cat foo.zsh
cat: foo.zsh: No such file or directory
% cat dir/foo.zsh
print foo
% PATH=./dir
% /bin/zsh -o PATH_SCRIPT foo.zsh
foo
% /bin/zsh +o PATH_SCRIPT foo.zsh
/bin/zsh: can't open input file: foo.zsh

--
vq



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