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:
parent
b230a690fa
commit
11440d17d1
3 changed files with 18 additions and 6 deletions
|
|
@ -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>
|
||||
|
||||
* "Akinori MUSHA: 27892: Completion/Redhat/Command/.distfiles,
|
||||
|
|
@ -13040,5 +13045,5 @@
|
|||
|
||||
*****************************************************
|
||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||
* $Revision: 1.4959 $
|
||||
* $Revision: 1.4960 $
|
||||
*****************************************************
|
||||
|
|
|
|||
15
Src/subst.c
15
Src/subst.c
|
|
@ -1386,7 +1386,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
|||
int plan9 = isset(RCEXPANDPARAM);
|
||||
/*
|
||||
* 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);
|
||||
/*
|
||||
|
|
@ -1899,12 +1900,12 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
|||
* spsep, NULL means $IFS.
|
||||
*/
|
||||
} else if (c == '~' || c == Tilde) {
|
||||
/* GLOB_SUBST on or off (doubled) */
|
||||
/* GLOB_SUBST (forced) on or off (doubled) */
|
||||
if ((c = *++s) == '~' || c == Tilde) {
|
||||
globsubst = 0;
|
||||
s++;
|
||||
} else
|
||||
globsubst = 1;
|
||||
globsubst = 2;
|
||||
} else if (c == '+') {
|
||||
/*
|
||||
* Return whether indicated parameter is set.
|
||||
|
|
@ -1935,7 +1936,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
|||
break;
|
||||
}
|
||||
/* 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.
|
||||
|
|
@ -2417,7 +2419,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
|||
multsub(&val, spbreak && !aspar, (aspar ? NULL : &aval), &isarr, NULL);
|
||||
opts[SHWORDSPLIT] = ws;
|
||||
copied = 1;
|
||||
spbreak = globsubst = 0;
|
||||
spbreak = 0;
|
||||
/* Leave globsubst on if forced */
|
||||
if (globsubst != 2)
|
||||
globsubst = 0;
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
|
|
|
|||
|
|
@ -226,10 +226,12 @@
|
|||
foo="boring*"
|
||||
print ${foo+$foo}
|
||||
print ${foo+"$foo"}
|
||||
print ${~foo+"$foo"}
|
||||
)
|
||||
0:globsubst together with nested quoted expansion
|
||||
>boringfile
|
||||
>boring*
|
||||
>boringfile
|
||||
|
||||
print -l "${$(print one word)}" "${=$(print two words)}"
|
||||
0:splitting of $(...) inside ${...}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue