From 9ce000db220d0c676ff14cfe4fa436e6988f59ad Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Sat, 14 Nov 2015 21:22:17 -0800 Subject: 37115: update for changes in ${(P)...} evaluation. --- ChangeLog | 5 +++++ Completion/Unix/Command/_git | 2 +- Doc/Zsh/expn.yo | 27 ++++++++++++++++++++++----- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52c770b00..a27c49817 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-11-14 Barton E. Schaefer + + * 37115: Completion/Unix/Commmand/_git, Doc/Zsh/expn.yo: update + for changes in ${(P)...} evaluation. + 2015-11-13 Daniel Shahaf * unposted: Src/Zle/zle_tricky.c: Make $EDITOR's diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 3dfd604e9..614185ebb 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -5244,7 +5244,7 @@ _git_commands () { for cmdtype in aliases $cmdtypes; do local -a ${cmdtype}_d (( $#disp )) && set -A ${cmdtype}_d \ - ${${(Pr.COLUMNS-4.)cmdtype/(#s)(#m)[^:]##:/${(r.len.)MATCH[1,-2]} $sep }%% #} + ${${(r.COLUMNS-4.)${(P)cmdtype}/(#s)(#m)[^:]##:/${(r.len.)MATCH[1,-2]} $sep }%% #} alts+=( "${cmdtype//_/-}:${${cmdtype//_/ }%%(e|)s}:compadd ${(e)disp} -a ${cmdtype}_m" ) done diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 4c373d1f2..6f08d7d47 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -1380,9 +1380,13 @@ outermost. The flags are not propagated up to enclosing substitutions; the nested substitution will return either a scalar or an array as determined by the flags, possibly adjusted for quoting. All the following steps take place where applicable at all levels of substitution. -Note that, unless the `tt((P))' flag is present, the flags and any subscripts -apply directly to the value of the nested substitution; for example, the -expansion tt(${${foo}}) behaves exactly the same as tt(${foo}). + +Note that, unless the `tt((P))' flag is present, the flags and any +subscripts apply directly to the value of the nested substitution; for +example, the expansion tt(${${foo}}) behaves exactly the same as +tt(${foo}). When the `tt((P))' flag is present in a nested substitution, +the other substitution rules are applied to the value em(before) it is +interpreted as a name, so tt(${${(P)foo}}) may differ from tt(${(P)foo}). At each nested level of substitution, the substituted words undergo all forms of single-word substitution (i.e. not filename generation), including @@ -1400,6 +1404,12 @@ in particular the tt(L), tt(R), tt(Z), tt(u) and tt(l) flags for padding and capitalization, are applied directly to the parameter value. Note these flags are options to the command, e.g. `tt(typeset -Z)'; they are not the same as the flags used within parameter substitutions. + +At the outermost level of substitution, the `tt((P))' flag ignores these +transformations and uses the unmodified value of the parameter as the name +to be replaced. This is usually the desired behavior because padding may +make the value syntactically illegal as a parameter name, but if +capitalization changes are desired, use the tt(${${(P)foo}}) form. ) item(tt(3.) em(Parameter subscripting))( If the value is a raw parameter reference with a subscript, such as @@ -1413,8 +1423,10 @@ original array). Any number of subscripts may appear. Flags such as tt((k)) and tt((v)) which alter the result of subscripting are applied. ) item(tt(4.) em(Parameter name replacement))( -The effect of any tt((P)) flag, which treats the value so far as a -parameter name and replaces it with the corresponding value, is applied. +At the outermost level of nesting only, the effect of any tt((P)) flag, +which treats the value so far as a parameter name and replaces it with the +corresponding value, is applied. This replacement occurs later if the +tt((P)) flag appears in a nested substitution. ) item(tt(5.) em(Double-quoted joining))( If the value after this process is an array, and the substitution @@ -1534,6 +1546,11 @@ Strictly speaking, the removal happens later as the same happens with other forms of substitution; the point to note here is simply that it occurs after any of the above parameter operations. ) +item(tt(25.) em(Parameter name replacement))( +If the `tt((P))' flag is present and this has not yet been done, the value +so far is looked up as a parameter name. Errors may occur if the value is +neither a valid identifier nor an identifier plus subscript expression. +) enditem() subsect(Examples) -- cgit 1.4.1