From 2fbc131ca81470a6b9aa077578f2eb58a7e8e008 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 17 Nov 2008 16:11:29 +0000 Subject: 26055: ensure process substitution is handled before parameter and command --- ChangeLog | 4 ++++ Doc/Zsh/expn.yo | 5 ++--- README | 8 +++----- Src/subst.c | 13 +++++++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c2bb184ad..e3e902d1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-11-17 Peter Stephenson + * 26055: README, Doc/Zsh/expn.yo, Src/subst.c: ensure process + substitution is handled completely before parameter and + command substitution. + * 26053: Completion/Base/Utility/_arguments: handle " --help" output that includes optional parts of options in square brackets. diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 2ab0d417e..2e5af790c 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -360,9 +360,8 @@ Each part of a command argument that takes the form is subject to process substitution. The expression may be preceeded or followed by other strings except that, to prevent clashes with commonly occurring strings and patterns, the last -form must occur at the start of a command argument, and none of -the forms may occur inside parentheses used for grouping of patterns or -inside parameter substitutions. +form must occur at the start of a command argument, and the forms +are only expanded when first parsing command or assignment arguments. In the case of the tt(<) or tt(>) forms, the shell runs the commands in var(list) asynchronously. If the system supports the tt(/dev/fd) diff --git a/README b/README index fd0537620..3eb6a1e28 100644 --- a/README +++ b/README @@ -74,11 +74,9 @@ were only handled if they appeared as separate command arguments. (However, the latter two forms caused the current argument to be terminated and a new one started even if they occurred in the middle of a string.) Now all three may be followed by other strings, and the -latter two may also be preceeded by other strings. None may occur inside -parameter substitutions, or inside parentheses used for grouping of -patterns, in order to avoid clashes with cases where -tt(<) or tt(>) were not treated specially in previous versions of the -shell. +latter two may also be preceeded by other strings. Remaining +limitations on their use (to reduce incompatibilities to a minimum) +are documented in the zshexpn.1 manual. In previous versions of the shell it was possible to use index 0 in an array or string subscript to refer to the same element as index 1 if the diff --git a/Src/subst.c b/Src/subst.c index 5cc4748b8..a8f894c68 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -152,8 +152,8 @@ stringsubst(LinkList list, LinkNode node, int ssub, int asssub) char *str = str3, c; while (!errflag && (c = *str)) { - if ((c == Inang || c == Outang || (str == str3 && c == Equals)) && - str[1] == Inpar) { + if (((c = *str) == Inang || c == Outang || (str == str3 && c == Equals)) + && str[1] == Inpar) { char *subst, *rest, *snew, *sptr; int str3len = str - str3, sublen, restlen; @@ -181,8 +181,13 @@ stringsubst(LinkList list, LinkNode node, int ssub, int asssub) str3 = snew; str = snew + str3len + sublen; setdata(node, str3); - continue; - } else if ((qt = c == Qstring) || c == String) { + } else + str++; + } + str = str3; + + while (!errflag && (c = *str)) { + if ((qt = c == Qstring) || c == String) { if ((c = str[1]) == Inpar) { if (!qt) list->list.flags |= LF_ARRAY; -- cgit 1.4.1