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
- X-seq: zsh-users 29565
- From: Lawrence Velázquez <larryv@xxxxxxx>
- To: "Steve Dondley" <s@xxxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: Can't tell the difference in operation between PATH_SCRIPT and NO_PATH_SCRIPT
- Date: Thu, 25 Jan 2024 22:05:10 -0500
- Archived-at: <https://zsh.org/users/29565>
- Feedback-id: iaa214773:Fastmail
- In-reply-to: <73E4333B-C282-4A58-837C-A50F73E13289@dondley.com>
- List-id: <zsh-users.zsh.org>
- References: <73E4333B-C282-4A58-837C-A50F73E13289@dondley.com>
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