* [BUG] NO_EXEC should not exec $NULLCMD
@ 2023-02-06 12:22 Marlon Richert
2023-02-06 14:33 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Marlon Richert @ 2023-02-06 12:22 UTC (permalink / raw)
To: Zsh hackers list
Steps to reproduce:
% PS1='%# ' zsh -f
% zsh -nc ': $( < $1 )'; print $?
zsh:1: no such file or directory:
1
%
Expected result:
% PS1='%# ' zsh -f
% zsh -nc ': $( < $1 )'; print $?
0
%
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG] NO_EXEC should not exec $NULLCMD
2023-02-06 12:22 [BUG] NO_EXEC should not exec $NULLCMD Marlon Richert
@ 2023-02-06 14:33 ` Peter Stephenson
2023-02-13 17:42 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2023-02-06 14:33 UTC (permalink / raw)
To: Zsh hackers list
> On 06/02/2023 12:22 Marlon Richert <marlon.richert@gmail.com> wrote:
> Steps to reproduce:
> % PS1='%# ' zsh -f
> % zsh -nc ': $( < $1 )'; print $?
> zsh:1: no such file or directory:
> 1
$(<$1) is special syntax to open $1 and insert it on the command line;
it's nothing to do with $NULLCMD, nor is anything being executed.
So --- given the way NO_EXEC doesn't have a very detailed specification
in zsh --- I don't think it's actually violating any designed behaviour
(that's quite a weak statement in these parts).
However, it is a reasonable question whether the redirection should
be taking place here at all, as it doesn't in other cases when
NO_EXEC is set, even if that's mostly a side effect of where the NO_EXEC
logic lives, so it's certainly quite confusing. If not, it shouldn't
be hard to suppress.
pws
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG] NO_EXEC should not exec $NULLCMD
2023-02-06 14:33 ` Peter Stephenson
@ 2023-02-13 17:42 ` Peter Stephenson
0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2023-02-13 17:42 UTC (permalink / raw)
To: Zsh hackers list
> On 06/02/2023 14:33 Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> > On 06/02/2023 12:22 Marlon Richert <marlon.richert@gmail.com> wrote:
> > Steps to reproduce:
> > % PS1='%# ' zsh -f
> > % zsh -nc ': $( < $1 )'; print $?
> > zsh:1: no such file or directory:
> > 1
>
> $(<$1) is special syntax to open $1 and insert it on the command line;
> it's nothing to do with $NULLCMD, nor is anything being executed.
> So --- given the way NO_EXEC doesn't have a very detailed specification
> in zsh --- I don't think it's actually violating any designed behaviour
> (that's quite a weak statement in these parts).
>
> However, it is a reasonable question whether the redirection should
> be taking place here at all, as it doesn't in other cases when
> NO_EXEC is set, even if that's mostly a side effect of where the NO_EXEC
> logic lives, so it's certainly quite confusing. If not, it shouldn't
> be hard to suppress.
This is probably uncontroversial.
pws
diff --git a/Src/exec.c b/Src/exec.c
index c8eb71b34..3330bbce8 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4678,6 +4678,9 @@ getoutput(char *cmd, int qt)
if (!prog)
return NULL;
+ if (!isset(EXECOPT))
+ return newlinklist();
+
if ((s = simple_redir_name(prog, REDIR_READ))) {
/* $(< word) */
int stream;
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index d38fbed74..533e08773 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -416,6 +416,9 @@
1:NO_EXEC does recognize bad substitution syntax
*?* bad substitution
+ (setopt noexec; : $(<nonexistentfile))
+0:NO_EXEC does not attempt to read files in $(<....)
+
setopt NO_eval_lineno
eval 'print $LINENO'
setopt eval_lineno
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-13 17:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06 12:22 [BUG] NO_EXEC should not exec $NULLCMD Marlon Richert
2023-02-06 14:33 ` Peter Stephenson
2023-02-13 17:42 ` Peter Stephenson
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).