1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-29 05:21:00 +01:00

27889: Force more use of GLOB_SUBST in parameters if ~ is used

This commit is contained in:
Peter Stephenson 2010-04-20 21:16:21 +00:00
parent b230a690fa
commit 11440d17d1
3 changed files with 18 additions and 6 deletions

View file

@ -1,3 +1,8 @@
2010-04-20 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 27889: Src/subst.c, Test/D04parameter.ztst: Force more use of
GLOB_SUBST in parameters if ~ is used.
2010-04-20 Peter Stephenson <pws@csr.com> 2010-04-20 Peter Stephenson <pws@csr.com>
* "Akinori MUSHA: 27892: Completion/Redhat/Command/.distfiles, * "Akinori MUSHA: 27892: Completion/Redhat/Command/.distfiles,
@ -13040,5 +13045,5 @@
***************************************************** *****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL * This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4959 $ * $Revision: 1.4960 $
***************************************************** *****************************************************

View file

@ -1386,7 +1386,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
int plan9 = isset(RCEXPANDPARAM); int plan9 = isset(RCEXPANDPARAM);
/* /*
* Likwise, but with ~ and ~~. Also, we turn it off later * Likwise, but with ~ and ~~. Also, we turn it off later
* on if qt is passed down. * on if qt is passed down. The value can go to 2 if we
* use ~ to force this on.
*/ */
int globsubst = isset(GLOBSUBST); int globsubst = isset(GLOBSUBST);
/* /*
@ -1899,12 +1900,12 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
* spsep, NULL means $IFS. * spsep, NULL means $IFS.
*/ */
} else if (c == '~' || c == Tilde) { } else if (c == '~' || c == Tilde) {
/* GLOB_SUBST on or off (doubled) */ /* GLOB_SUBST (forced) on or off (doubled) */
if ((c = *++s) == '~' || c == Tilde) { if ((c = *++s) == '~' || c == Tilde) {
globsubst = 0; globsubst = 0;
s++; s++;
} else } else
globsubst = 1; globsubst = 2;
} else if (c == '+') { } else if (c == '+') {
/* /*
* Return whether indicated parameter is set. * Return whether indicated parameter is set.
@ -1935,7 +1936,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
break; break;
} }
/* Don't activate special pattern characters if inside quotes */ /* Don't activate special pattern characters if inside quotes */
globsubst = globsubst && !qt; if (qt)
globsubst = 0;
/* /*
* At this point, we usually expect a parameter name. * At this point, we usually expect a parameter name.
@ -2417,7 +2419,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
multsub(&val, spbreak && !aspar, (aspar ? NULL : &aval), &isarr, NULL); multsub(&val, spbreak && !aspar, (aspar ? NULL : &aval), &isarr, NULL);
opts[SHWORDSPLIT] = ws; opts[SHWORDSPLIT] = ws;
copied = 1; copied = 1;
spbreak = globsubst = 0; spbreak = 0;
/* Leave globsubst on if forced */
if (globsubst != 2)
globsubst = 0;
} }
break; break;
case ':': case ':':

View file

@ -226,10 +226,12 @@
foo="boring*" foo="boring*"
print ${foo+$foo} print ${foo+$foo}
print ${foo+"$foo"} print ${foo+"$foo"}
print ${~foo+"$foo"}
) )
0:globsubst together with nested quoted expansion 0:globsubst together with nested quoted expansion
>boringfile >boringfile
>boring* >boring*
>boringfile
print -l "${$(print one word)}" "${=$(print two words)}" print -l "${$(print one word)}" "${=$(print two words)}"
0:splitting of $(...) inside ${...} 0:splitting of $(...) inside ${...}