mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-29 05:21:00 +01:00
33118: record original param unset state when treating empty the same as unset,
to avoid incorrect NO_UNSET errors
This commit is contained in:
parent
4414e54ea7
commit
5a9f3ac773
2 changed files with 13 additions and 6 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
2014-09-06 Barton E. Schaefer <schaefer@zsh.org>
|
2014-09-06 Barton E. Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* 33118: Src/subst.c: record original param unset state when
|
||||||
|
${name:#word} et al. need to treat empty the same as unset, to
|
||||||
|
avoid incorrect NO_UNSET error
|
||||||
|
|
||||||
* 33116: Src/hist.c: followup to 32580 to prevent double-locking
|
* 33116: Src/hist.c: followup to 32580 to prevent double-locking
|
||||||
with shared or incremental history
|
with shared or incremental history
|
||||||
|
|
||||||
|
|
|
||||||
15
Src/subst.c
15
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
|
* unset. I don't quite understand why (v == NULL) isn't
|
||||||
* good enough, but there are places where we seem to need
|
* good enough, but there are places where we seem to need
|
||||||
* to second guess whether a value is a real value or not.
|
* to second guess whether a value is a real value or not.
|
||||||
|
* See in particular the (colf && !vunset) test below.
|
||||||
*/
|
*/
|
||||||
int vunset = 0;
|
int vunset = 0;
|
||||||
/*
|
/*
|
||||||
|
|
@ -2638,8 +2639,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
|
||||||
* - (array) contains no elements
|
* - (array) contains no elements
|
||||||
* - (scalar) contains an empty string
|
* - (scalar) contains an empty string
|
||||||
*/
|
*/
|
||||||
if (colf && !vunset)
|
if (colf && !vunset) {
|
||||||
vunset = (isarr) ? !*aval : !*val || (*val == Nularg && !val[1]);
|
vunset = (isarr) ? !*aval : !*val || (*val == Nularg && !val[1]);
|
||||||
|
vunset *= -1; /* Record that vunset was originally false */
|
||||||
|
}
|
||||||
|
|
||||||
switch (s[-1]) {
|
switch (s[-1]) {
|
||||||
case '+':
|
case '+':
|
||||||
|
|
@ -2862,7 +2865,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
|
||||||
getmatcharr(&aval, s, flags, flnum, replstr);
|
getmatcharr(&aval, s, flags, flnum, replstr);
|
||||||
} else {
|
} else {
|
||||||
if (vunset) {
|
if (vunset) {
|
||||||
if (unset(UNSET)) {
|
if (vunset > 0 && unset(UNSET)) {
|
||||||
*idend = '\0';
|
*idend = '\0';
|
||||||
zerr("%s: parameter not set", idbeg);
|
zerr("%s: parameter not set", idbeg);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -2892,7 +2895,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (vunset) {
|
if (vunset) {
|
||||||
if (unset(UNSET)) {
|
if (vunset > 0 && unset(UNSET)) {
|
||||||
*idend = '\0';
|
*idend = '\0';
|
||||||
zerr("%s: parameter not set", idbeg);
|
zerr("%s: parameter not set", idbeg);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -2974,7 +2977,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
|
||||||
*ap = NULL;
|
*ap = NULL;
|
||||||
} else {
|
} else {
|
||||||
if (vunset) {
|
if (vunset) {
|
||||||
if (unset(UNSET)) {
|
if (vunset > 0 && unset(UNSET)) {
|
||||||
*idend = '\0';
|
*idend = '\0';
|
||||||
zerr("%s: parameter not set", idbeg);
|
zerr("%s: parameter not set", idbeg);
|
||||||
deletehashtable(ht);
|
deletehashtable(ht);
|
||||||
|
|
@ -3003,7 +3006,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vunset) {
|
if (vunset) {
|
||||||
if (unset(UNSET)) {
|
if (vunset > 0 && unset(UNSET)) {
|
||||||
*idend = '\0';
|
*idend = '\0';
|
||||||
zerr("%s: parameter not set", idbeg);
|
zerr("%s: parameter not set", idbeg);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -3020,7 +3023,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
|
||||||
val = dupstring(vunset ? "0" : "1");
|
val = dupstring(vunset ? "0" : "1");
|
||||||
isarr = 0;
|
isarr = 0;
|
||||||
} else if (vunset) {
|
} else if (vunset) {
|
||||||
if (unset(UNSET)) {
|
if (vunset > 0 && unset(UNSET)) {
|
||||||
*idend = '\0';
|
*idend = '\0';
|
||||||
zerr("%s: parameter not set", idbeg);
|
zerr("%s: parameter not set", idbeg);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue