From mboxrd@z Thu Jan 1 00:00:00 1970
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org
X-Spam-Level:
X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,
DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham
autolearn_force=no version=3.4.4
Received: (qmail 18771 invoked from network); 16 Jan 2023 17:15:52 -0000
Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368)
by inbox.vuxu.org with ESMTPUTF8; 16 Jan 2023 17:15:52 -0000
ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1673889352;
b=OdSiAGYnV4mOhU1qQiq/BKwmPFRXb6NNd+dVXUpV7wgIcEOjDTEHjuqCxZSAxlyyZVFyWpD0ap
e0ri3xnSQzK6bS0x1fhsfmgSTHZCN68t8Z+o+65nKkuwwTyPmY4ILFHaBnjhjN8pwX/t4r5WbP
yKS168O0d93km/mUntlhkFIRnrz10OADDj60qsU4pJ00hBy3DByZot4wAkZVuF7H5UXNvnztEB
ydUGX8VIxRu2HL7KryB1KSbDwIL71cgo+iOtk3O0amUoCpOK3iwOEC9bmXcDRaQGJbTvp4uo+x
gA9+xp1Q6ZSqeSUDpQqSVYHkwOhfnh+eiMKsBil3m866Vw==;
ARC-Authentication-Results: i=1; zsh.org;
iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1673889352;
bh=J04T2HyulXmMiku6JTUOsrotMLtuoHoZr956z9iS6SE=;
h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help:
List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:
References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature:
DKIM-Signature;
b=GEyxhfpDGw7ZlLvo+OOqpeftlUtkw/HsCjtBg5nOnsdvz7sA30G3oZp6lbeVD3Dmsd+d3QTw1X
2TXnt9HRgh5GLeE1RG4/+oFvOyBTmSjMzSZgU3WSsjxHiKeZxJpwxBkJenCd0IEO3jquIRP6j9
yFb1TFbf8+PRB7FkoeaZgp32CxPXs5xyIBPxR3Sd9I4Li+GjGD2xynZc73uLDhj/kzg6Mjm50E
ySHhpblE3AABZ5pZfVIDSqsMrLxGUFYJo5fNrAhMXjWlywS81bD1LVuSfDG8B/x93QVEw7/7QP
kXJRTeuDU78ufahIe9aQLmL8Pb6DnPTke27mBwxylNkdgg==;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org;
s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:
List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding:
Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From:
Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:
Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=5r4TvQMUw86RwSbZ27OHRNB947SVdrG2JVukqRLcjYA=; b=niyOQA7ASAhNSSklHvFuo7kjOw
9iA7QcVoE72tdstRgvqR0YuZaJpUhMeNFCaFKlP/rR8s4OiwIBi+vKf7Jcjx/VfER+7IfPWPsoiJK
w+LxD0PGdtoyaNG6jmmczku8HC5QER9HxdCTZrCIjgBhmAEc8uu8bx53OQOAsduL2QA6jN5BrCVB9
EYzdq0vrC/14mTLkT6qX5HXbV7nnQ87XwqgqYQiTR+8ysYSg/CvzCE4TQkoqrLmViFCyoVjIAXqGy
CkT2GD8u0Bk43hF/lLnVXJdTnwRDBhd4v4toG3fHF1yGdKmejgwWraoGh+XtQUJDikaBtuW3I70ng
Rg4dUmaA==;
Received: by zero.zsh.org with local
id 1pHT5L-000GD2-Ph;
Mon, 16 Jan 2023 17:15:51 +0000
Authentication-Results: zsh.org;
iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
Received: from smtpq1.tb.ukmail.iss.as9143.net ([212.54.57.96]:53414)
by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
id 1pHT55-000FtK-U1;
Mon, 16 Jan 2023 17:15:37 +0000
Received: from [212.54.57.81] (helo=smtp2.tb.ukmail.iss.as9143.net)
by smtpq1.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1)
(envelope-from
)
id 1pHT55-00048U-BB
for zsh-workers@zsh.org; Mon, 16 Jan 2023 18:15:35 +0100
Received: from oxbe21.tb.ukmail.iss.as9143.net ([172.25.160.152])
by smtp2.tb.ukmail.iss.as9143.net with ESMTP
id HT55pnJn06AslHT55pIJGw; Mon, 16 Jan 2023 18:15:35 +0100
X-Env-Mailfrom: p.w.stephenson@ntlworld.com
X-Env-Rcptto: zsh-workers@zsh.org
X-SourceIP: 172.25.160.152
X-CNFS-Analysis: v=2.4 cv=c8ttAzxl c=1 sm=1 tr=0 ts=63c58637 cx=a_exe
a=I3kh1BFku3bnNore5KbC7A==:117 a=1DWFKdCB1IcA:10 a=IkcTkHD0fZMA:10
a=ZjyAdWuDOD4A:10 a=N898d1J4AAAA:8 a=EisBt-vyZhoN-UXYgpcA:9 a=QEXdDO2ut3YA:10
a=4OhKILdWXy8MGewZJRtY:22
X-Authenticated-Sender: p.w.stephenson@ntlworld.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com;
s=meg.feb2017; t=1673889335;
bh=J04T2HyulXmMiku6JTUOsrotMLtuoHoZr956z9iS6SE=;
h=Date:From:To:In-Reply-To:References:Subject;
b=ESapJD03YJ2ldExzXaY+DMFYT9JWLF/SY3nxIce6AI10BlgirPR3XXRy14lQcDLxL
sFAN0s7wNpSBVhnMXN0DKrBo0RJJv4L1q9ZzTP48oGGmJ9qQvYevhQEzfwqZNPpkxy
vj+4mLhQYjbegrOhNd5Zxk39R0JuG09p3ygYLtb4IMUyhWOnQ3ynF/ClPDdVCgoHYd
t9nd2iWWmsc9VBNcJAL9QTKcnLMHkjbJsC6aK8HKYfWNqVem2eA9H79ycT3OaAUuwa
oZASrz9TYnfUlSElp7Zp4Hd2B3GdwdxvIpEMojXF3+VT8n7iro74FbwIgJsK9gyHsN
KFGm98dYlbfcw==
Date: Mon, 16 Jan 2023 17:15:35 +0000 (GMT)
From: Peter Stephenson
To: zsh workers
Message-ID: <836025199.2014747.1673889335246@mail.virginmedia.com>
In-Reply-To: <20230113080246.nghigc4givvaomve@chazelas.org>
References: <20230113080246.nghigc4givvaomve@chazelas.org>
Subject: Re: $var not expanded in ${x?$var}
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Priority: 3
Importance: Normal
X-Mailer: Open-Xchange Mailer
X-Originating-IP: 147.161.224.167
X-Originating-Client: open-xchange-appsuite
X-CMAE-Envelope: MS4xfDf9ZYEwoifqrZ5wWgViP63a8VWht+tn2uXPRVNvjICrjQRq8wGnN34OXlOlYwyxpoVHUCBIcNNtD88ZyjLboj8hE5mXvFACNw8D8HBuP8dHhLbkmiq3
mRwDjh3W+JFSncoxFGYT40+zWHXCcMLyqHiMMoYLnD1603HN6nQXJlxq+eiMGz0g5pPrNAmviwMqPGFa390MDc0SXWNqPuFWvTjfNA2bARJYsyWr7jpNOQBD
X-Seq: 51306
Archived-At:
X-Loop: zsh-workers@zsh.org
Errors-To: zsh-workers-owner@zsh.org
Precedence: list
Precedence: bulk
Sender: zsh-workers-request@zsh.org
X-no-archive: yes
List-Id:
List-Help: ,
List-Subscribe: ,
List-Unsubscribe: ,
List-Post:
List-Owner:
List-Archive:
> On 13/01/2023 08:02 Stephane Chazelas wrote:
>
>
> $ zsh -c 'echo ${1?$USERNAME}'
> zsh:1: 1: $USERNAME
>
> No quote removal either:
>
> $ zsh -c 'echo ${1?"x"}'
> zsh:1: 1: "x"
>
> Doc says:
>
> > In any of the above expressions that test a variable and substitute an
> > alternate WORD, note that you can use standard shell quoting in the WORD
> > value to selectively override the splitting done by the SH_WORD_SPLIT
> > option and the = flag, but not splitting by the s:STRING: flag.
In fact the shell does not "substitute an alternate WORD" here, it
just prints it out, but the difference is easy to miss and expanding it
seems the right thing to do from other points of view, so I've noted it
in the doc.
pws
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index eb8cdbae5..857715a95 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 6bf55b4db..7dd5d82d7 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:${...:+...}, ${...+...}