zsh-users
 help / color / mirror / code / Atom feed
From: Steve Dondley <s@dondley.com>
To: "Lawrence Velázquez" <larryv@zsh.org>
Cc: zsh-users@zsh.org
Subject: Re: Can't tell the difference in operation between PATH_SCRIPT and NO_PATH_SCRIPT
Date: Fri, 26 Jan 2024 00:20:03 -0500	[thread overview]
Message-ID: <2CF29A22-6721-4275-8E92-7FF61CE4CDCB@dondley.com> (raw)
In-Reply-To: <c7b3081f-4a7c-41a3-8ca2-46efd995ae75@app.fastmail.com>

[-- Attachment #1: Type: text/plain, Size: 2987 bytes --]

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 <larryv@zsh.org> 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


[-- Attachment #2: Type: text/html, Size: 38224 bytes --]

  reply	other threads:[~2024-01-26  5:21 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26  2:00 Steve Dondley
2024-01-26  3:05 ` Lawrence Velázquez
2024-01-26  3:21   ` Steve Dondley
2024-01-26  3:30     ` Steve Dondley
2024-01-26  3:45     ` Lawrence Velázquez
2024-01-26  4:17       ` Steve Dondley
2024-01-26  4:58         ` Lawrence Velázquez
2024-01-26  5:20           ` Steve Dondley [this message]
2024-01-26  5:52             ` Bart Schaefer
2024-01-26  6:35               ` Lawrence Velázquez
2024-01-26 15:49               ` Steve Dondley
2024-01-26 16:07                 ` Mark J. Reed
2024-01-26 16:41                   ` Mark J. Reed
2024-01-26 17:21                     ` Steve Dondley
2024-01-26 18:28                       ` Ray Andrews
2024-01-26 18:38                         ` Roman Perepelitsa
2024-01-26 19:17                           ` Steve Dondley
2024-01-26 19:38                             ` Roman Perepelitsa
2024-01-26 19:52                               ` Steve Dondley
2024-01-26 20:06                                 ` Ray Andrews
2024-01-26 20:16                                   ` Lawrence Velázquez
2024-01-26 19:54                             ` Ray Andrews
2024-01-26 20:05                               ` Steve Dondley
2024-01-26 20:43                               ` Steve Dondley
2024-01-27  2:34                             ` .m0rph
2024-01-26 19:42                           ` Ray Andrews
2024-01-26 20:08                             ` Roman Perepelitsa
2024-01-26 20:21                               ` Steve Dondley
2024-01-26 20:40                               ` Ray Andrews
2024-01-26  6:25             ` Lawrence Velázquez
2024-01-26  6:42               ` Lawrence Velázquez
2024-01-26 15:27               ` Steve Dondley
2024-01-26  4:35 ` Lawrence Velázquez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2CF29A22-6721-4275-8E92-7FF61CE4CDCB@dondley.com \
    --to=s@dondley.com \
    --cc=larryv@zsh.org \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).