mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-28 06:49:49 +02:00
41877: Separate out SH_FILE_EXPANSION loop from parameter substitution.
Parameter substitution can add nodes that need to be rescanned by it, but not by file expansion, so the two don't play well together.
This commit is contained in:
parent
57cfa8b160
commit
b3fa5c528c
@ -1,3 +1,11 @@
|
||||
2017-10-13 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 41877: Src/subst·c, Test/E01options.ztst: Separate out
|
||||
SH_FILE_EXPANSION loop from parameter substitution as the latter
|
||||
can add nodes: SH_FILE_EXPANSION should see following nodes
|
||||
only, but on the next loop parameter substitution needs to see
|
||||
added nodes for further expansion.
|
||||
|
||||
2017-10-11 Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
|
||||
|
||||
* 41825/0002: Completion/Zsh/Command/_stat: Complete -x options
|
||||
|
39
Src/subst.c
39
Src/subst.c
@ -108,7 +108,6 @@ prefork(LinkList list, int flags, int *ret_flags)
|
||||
queue_signals();
|
||||
node = firstnode(list);
|
||||
while (node) {
|
||||
LinkNode nextnode = 0;
|
||||
if ((flags & (PREFORK_SINGLE|PREFORK_ASSIGN)) == PREFORK_ASSIGN &&
|
||||
(insnode = keyvalpairelement(list, node))) {
|
||||
node = insnode;
|
||||
@ -137,23 +136,31 @@ prefork(LinkList list, int flags, int *ret_flags)
|
||||
* testing if cptr changed...
|
||||
*/
|
||||
setdata(node, cptr);
|
||||
/*
|
||||
* Advance now because we must not expand filenames again
|
||||
* after string substitution (which may insert new nodes).
|
||||
*/
|
||||
nextnode = node;
|
||||
incnode(nextnode);
|
||||
}
|
||||
if (!(node = stringsubst(list, node,
|
||||
flags & ~(PREFORK_TYPESET|PREFORK_ASSIGN),
|
||||
ret_flags, asssub))) {
|
||||
unqueue_signals();
|
||||
return;
|
||||
}
|
||||
if (isset(SHFILEEXPANSION))
|
||||
node = nextnode;
|
||||
else
|
||||
incnode(node);
|
||||
{
|
||||
if (!(node = stringsubst(list, node,
|
||||
flags & ~(PREFORK_TYPESET|PREFORK_ASSIGN),
|
||||
ret_flags, asssub))) {
|
||||
unqueue_signals();
|
||||
return;
|
||||
}
|
||||
}
|
||||
incnode(node);
|
||||
}
|
||||
if (isset(SHFILEEXPANSION)) {
|
||||
/*
|
||||
* stringsubst() may insert new nodes, so doesn't work
|
||||
* well in the same loop as file expansion.
|
||||
*/
|
||||
for (node = firstnode(list); node; incnode(node)) {
|
||||
if (!(node = stringsubst(list, node,
|
||||
flags & ~(PREFORK_TYPESET|PREFORK_ASSIGN),
|
||||
ret_flags, asssub))) {
|
||||
unqueue_signals();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (node = firstnode(list); node; incnode(node)) {
|
||||
if (node == stop)
|
||||
|
@ -1038,6 +1038,16 @@ F:Regression test for workers/41811
|
||||
>~/one
|
||||
>~/two
|
||||
|
||||
(
|
||||
setopt shfileexpansion
|
||||
set -- also appearing
|
||||
print -l $*$*
|
||||
)
|
||||
0:SH_FILE_EXPANSION interaction with inserting nodes from parameters
|
||||
>also
|
||||
>appearingalso
|
||||
>appearing
|
||||
|
||||
testpat() {
|
||||
if [[ $1 = ${~2} ]]; then print $1 $2 yes; else print $1 $2 no; fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user