OK, thanks. At the risk of dragging this on, allow me to ask this simple question to make sure I got it: Is there any way to run this command by itself on the command line: > setopt pathscript And have it affect the outcome of any subsequent commands? It looks like the answer is no. It looks to me like the pathscript setting can only affect future commands if it’s either: a) used with +o or -o as part of an argument passed directly to zsh while running a script b) or if it’s set in a .zshrc file (or other config file) and then sourced when a new shell (interactive mode) Please tell me I have this correct otherwise I’m still badly confused. > On Jan 25, 2024, at 11:58 PM, Lawrence Velázquez wrote: > > On Thu, Jan 25, 2024, at 11:17 PM, Steve Dondley wrote: >> 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. > > You're overgeneralizing. PATH_SCRIPT is defined to only affect the > latter scenario, but you are confused because you have been trying > to apply it to the former scenario. There is no broader lesson > about options here. > > It's like being confused that POSIX_CD doesn't make the jobs(1) > builtin more POSIX-conformant, even though it never claimed to. > It is a category mistake. > > >> 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. > > Options are not inherited by child shells created in this manner. > That is why my demonstration used -o and +o. > > % ([[ -o EXTENDED_GLOB ]]; print $?) > 1 > % setopt EXTENDED_GLOB > % ([[ -o EXTENDED_GLOB ]]; print $?) > 0 > % zsh -c '[[ -o EXTENDED_GLOB ]]; print $?' > 1 > > >> HOWEVER, I discovered if I put this in my .zshrc: >> >> setopt pathscript >> >> and do: >> >>> zsh -i foo.zsh >> >> It works. > > Yes, because interactive shells source .zshrc. > > >> Or, if I do >> >>> setopt pathscript >> >> and then do >> >>> zsh -c foo.zsh >> >> This also works. > > No, you are conflating unrelated things again. With -c, zsh evaluates > the "foo.zsh" argument as a complete script, so it performs a PATH > search as usual. As I said earlier, PATH_SCRIPT *does not apply* to > ''zsh -c''; its status is irrelevant. > > % cat foo.sh > cat: foo.sh: No such file or directory > % cat dir/foo.sh > echo foo > % PATH=./dir /bin/zsh -o PATH_SCRIPT -c foo.sh > foo > % PATH=./dir /bin/zsh +o PATH_SCRIPT -c foo.sh > foo > > > -- > vq