help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] NO_EXEC should not exec $NULLCMD
Date: Mon, 13 Feb 2023 17:42:48 +0000 (GMT)	[thread overview]
Message-ID: <1106715548.16569.1676310168881@mail.virginmedia.com> (raw)
In-Reply-To: <1721279218.10760102.1675694027023@mail.virginmedia.com>

> 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.


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

      reply	other threads:[~2023-02-13 17:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 12:22 Marlon Richert
2023-02-06 14:33 ` Peter Stephenson
2023-02-13 17:42   ` Peter Stephenson [this message]

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:

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

  git send-email \
    --in-reply-to=1106715548.16569.1676310168881@mail.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \


* 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


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).