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



When you set an option with setopt, that sets it for the shell you are already in and typing commands to. 

When you run /bin/zsh as a command, you are starting up a brand new shell that does not inherit those options.

zsh% setopt pathscript                
zsh% set -o | grep pathscript        
pathscript            on
zsh% zsh -c 'set -o | grep pathscript'
pathscript            off

So doing setopt pathscript has no effect whatsoever on what a subsequent /bin/zsh some_script will do. You have to do this instead:

/bin/zsh -o pathscript some_script


On Fri, Jan 26, 2024 at 10:50 AM Steve Dondley <s@xxxxxxxxxxx> wrote:


You have this almost correct.  Sourcing for interactive mode has
nothing to do with it.  It always applies to the scriptname argument
passed to a new zsh, so it has to be in effect before zsh searches for
the script.

I may not be following you here.

If I have a script at ./dir/some_script and I do:

> PATH=./dir
> setopt pathscript

Then do

> /bin/zsh some_script

It will not look for the script in $PATH as far as I can tell and fails with zsh: can't open input file: some_script

You are saying my last command above should work with pathscript on? 


--
Mark J. Reed <markjreed@xxxxxxxxx>


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