about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2023-02-02 10:12:17 +0000
committerPeter Stephenson <p.stephenson@samsung.com>2023-02-02 10:12:17 +0000
commit76d095df9de31d46b0ca042039855ffc286f5fdb (patch)
tree6c735048daa3773cb741b3b816d2acba4085f691
parent21baad1037c1aa85384a81dd77a4661676336133 (diff)
downloadzsh-76d095df9de31d46b0ca042039855ffc286f5fdb.tar.gz
zsh-76d095df9de31d46b0ca042039855ffc286f5fdb.tar.xz
zsh-76d095df9de31d46b0ca042039855ffc286f5fdb.zip
51306: error message in ${unset?error} should be expanded
-rw-r--r--ChangeLog3
-rw-r--r--Doc/Zsh/expn.yo4
-rw-r--r--Src/subst.c6
-rw-r--r--Test/D04parameter.ztst5
4 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ee9a623d4..6bdaeedbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2023-02-02  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 51306: Doc/Zsh/expn.yo, Src/subst.c, Test/D04parameter.ztst:
+	error message in ${unset?...} should be expanded.
+
 	* 51307: Src/input.c, Src/parse.c, Test/A02alias.ztst: error
 	on attempt to expand alias in function definition name didn't
 	find the original alias and printed an extra error.
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index ad55c24ba..fd5443b20 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -665,7 +665,9 @@ item(tt(${)var(name)tt(:?)var(word)tt(}))(
 In the first form, if var(name) is set, or in the second form if var(name)
 is both set and non-null, then substitute its value; otherwise, print
 var(word) and exit from the shell.  Interactive shells instead return to
-the prompt.  If var(word) is omitted, then a standard message is printed.
+the prompt.  If var(word) is omitted, then a standard message is
+printed.  Note that var(word) is expanded even though its value
+is not substituted onto the command line.
 )
 enditem()
 
diff --git a/Src/subst.c b/Src/subst.c
index 897188862..4ad9fee1a 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -3076,7 +3076,11 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
 	    if (vunset) {
                 if (isset(EXECOPT)) {
                     *idend = '\0';
-                    zerr("%s: %s", idbeg, *s ? s : "parameter not set");
+		    if (*s){
+			singsub(&s);
+			zerr("%s: %s", idbeg, s);
+		    } else
+			zerr("%s: %s", idbeg, "parameter not set");
                     /*
                      * In interactive shell we need to return to
                      * top-level prompt --- don't clear this error
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 29275f13f..a11652d1e 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -110,6 +110,11 @@
 *>*foo:1: 1: no arguments given
 >reached
 
+  message="expand me and remove quotes"
+  (: ${UNSET_PARAM?$message})
+1:${...?....} performs expansion on the message
+?(eval):2: UNSET_PARAM: expand me and remove quotes
+
   print ${set1:+word1} ${set1+word2} ${null1:+word3} ${null1+word4}
   print ${unset1:+word5} ${unset1+word6}
 0:${...:+...}, ${...+...}