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



I guess I never realized that, when it comes to options, there is a difference between running a script directly and passing it as an argument to zsh. 

But even still, If I do this:

> echo $PATH
/usr/bin:./dir

> ls dir
-rwxr--r-- 1 root root 9 Jan 26 03:26 foo.zsh

> setopt pathscript

> zsh foo.zsh
zsh: can't open input file: foo.zsh

> unsetopt pathscript

> zsh foo.zsh
zsh: can't open input file: foo.zsh


So I’m still seeing no difference between execution of the script with path script on or off in these cases.

HOWEVER, I discovered if I put this in my .zshrc:

setopt pathscript

and do:

> zsh -i foo.zsh

It works.


Or, if I do

> setopt pathscript

and then do

> zsh -c foo.zsh

This also works.

> zsh -i foo.zsh wil also work in this case, too. 




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

On Thu, Jan 25, 2024, at 10:21 PM, Steve Dondley wrote:
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. 

You doing something completely different from what I described and
demonstrated.  PATH_SCRIPT *only* affects how zsh behaves when you
invoke it to run a script (e.g., ''zsh script_name'').  It does not
affect PATH searches performed as part of command execution.

-- 
vq



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