From 7e0c4406ceba1e021bf37680d6a6b8dcd3dd657f Mon Sep 17 00:00:00 2001
From: Peter Stephenson <p.stephenson@samsung.com>
Date: Tue, 14 Feb 2023 09:21:19 +0000
Subject: [PATCH] 51424: $(<...) shouldn't try to open a file with NO_EXEC

---
 ChangeLog            | 5 +++++
 Src/exec.c           | 3 +++
 Test/E01options.ztst | 3 +++
 3 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index be0d8d5e1..b490b0ee8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-02-14  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 51425: Src/exec.c, Test/E01OPTIONS: $(<...) shouldn't try to
+	open a file with NO_EXEC.
+
 2023-02-13  Bart Schaefer  <schaefer@zsh.org>
 
 	* 51430: Src/Modules/parameter.c, Src/builtin.c, Src/params.c,
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