summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2014-09-06 22:15:28 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2014-09-06 22:15:28 -0700
commit5a9f3ac773f8b4c701654874c9da5da0d937b91c (patch)
treefff3e47937494708f3a803b147b658cf2c465174 /Src
parent4414e54ea7ffe50acca851c11c2ef49dc867c55d (diff)
downloadzsh-5a9f3ac773f8b4c701654874c9da5da0d937b91c.tar.gz
zsh-5a9f3ac773f8b4c701654874c9da5da0d937b91c.zip
33118: record original param unset state when treating empty the same as unset,
to avoid incorrect NO_UNSET errors
Diffstat (limited to 'Src')
-rw-r--r--Src/subst.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 4a5fe3a3c..1aa9b982e 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1522,6 +1522,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
* unset. I don't quite understand why (v == NULL) isn't
* good enough, but there are places where we seem to need
* to second guess whether a value is a real value or not.
+ * See in particular the (colf && !vunset) test below.
*/
int vunset = 0;
/*
@@ -2638,8 +2639,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
* - (array) contains no elements
* - (scalar) contains an empty string
*/
- if (colf && !vunset)
+ if (colf && !vunset) {
vunset = (isarr) ? !*aval : !*val || (*val == Nularg && !val[1]);
+ vunset *= -1; /* Record that vunset was originally false */
+ }
switch (s[-1]) {
case '+':
@@ -2862,7 +2865,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
getmatcharr(&aval, s, flags, flnum, replstr);
} else {
if (vunset) {
- if (unset(UNSET)) {
+ if (vunset > 0 && unset(UNSET)) {
*idend = '\0';
zerr("%s: parameter not set", idbeg);
return NULL;
@@ -2892,7 +2895,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
return NULL;
}
if (vunset) {
- if (unset(UNSET)) {
+ if (vunset > 0 && unset(UNSET)) {
*idend = '\0';
zerr("%s: parameter not set", idbeg);
return NULL;
@@ -2974,7 +2977,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
*ap = NULL;
} else {
if (vunset) {
- if (unset(UNSET)) {
+ if (vunset > 0 && unset(UNSET)) {
*idend = '\0';
zerr("%s: parameter not set", idbeg);
deletehashtable(ht);
@@ -3003,7 +3006,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
}
}
if (vunset) {
- if (unset(UNSET)) {
+ if (vunset > 0 && unset(UNSET)) {
*idend = '\0';
zerr("%s: parameter not set", idbeg);
return NULL;
@@ -3020,7 +3023,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
val = dupstring(vunset ? "0" : "1");
isarr = 0;
} else if (vunset) {
- if (unset(UNSET)) {
+ if (vunset > 0 && unset(UNSET)) {
*idend = '\0';
zerr("%s: parameter not set", idbeg);
return NULL;