zsh-workers
 help / color / mirror / code / Atom feed
* BUG: zsh-3.1.5-pws-14: parameter expansion not working properly
@ 1999-04-10 11:28 Geoff Wing
  1999-04-12  6:51 ` Andrej Borsenkow
  0 siblings, 1 reply; 3+ messages in thread
From: Geoff Wing @ 1999-04-10 11:28 UTC (permalink / raw)
  To: zsh-workers

Here's a fragment of the expansion similar to that used in
cvsentries() in Misc/compctl-examples 

% zsh-3.1.5
% a=("${(f@)$(echo foo; echo bar)}"); print -l $a
foo
bar
% a=("${${(f@)$(echo foo; echo bar)}:#f*}"); print -l $a
bar
% zsh-3.1.5-pws-14
% a=("${(f@)$(echo foo; echo bar)}"); print -l $a
foo
bar
% a=("${${(f@)$(echo foo; echo bar)}:#f*}"); print -l $a

%
-- 
Geoff Wing   <gcw@pobox.com>            Mobile : (Australia) 0412 162 441
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: zsh-3.1.5-pws-14: parameter expansion not working properly
  1999-04-10 11:28 BUG: zsh-3.1.5-pws-14: parameter expansion not working properly Geoff Wing
@ 1999-04-12  6:51 ` Andrej Borsenkow
  1999-04-12  7:35   ` Geoff Wing
  0 siblings, 1 reply; 3+ messages in thread
From: Andrej Borsenkow @ 1999-04-12  6:51 UTC (permalink / raw)
  To: mason, zsh-workers

Yes, as I understand, it was changed in pws-14. It includes full description
of subst rules in Parameters expansion section of manual.

Basically, in quotes, the value of inner substitution is always forced to be
scalar for outer substitution unless some flags or modifiers (notably, =,
(@), (s)) prevent it.
> % zsh-3.1.5-pws-14
> % a=("${(f@)$(echo foo; echo bar)}"); print -l $a
> foo
> bar

(@) is not needed. (f) is already enough - first, the value of $(...) is
forced to scalar and then it is splitted using (f) flag. The result is
*always* array - in this case it is top-level one so nothing more happens.

> % a=("${${(f@)$(echo foo; echo bar)}:#f*}"); print -l $a
>

Yep. The first ${(f)$(...)} yields array value. The outer ${...} first
converts array to scalar (because the whole is quoted) and then applies # to
scalar. To preserve "arrayness" you need (@) for outer subst:

bor@itsrm2:~%> a=("${(@)${(f@)$(echo foo; echo bar)}:#f*}"); print -l $a
bar

So, it is not a bug, it is by desing. There was a long thread here, where I
tried to understand what ZSH substitution rules actually are. I admit (now
:-) that current state is more or less consistent. The problem is, it is
near to impossible to explain difference between pws-14 and earlier versions
because it is the first time these rules are explicitly stated.

/andrej


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: zsh-3.1.5-pws-14: parameter expansion not working properly
  1999-04-12  6:51 ` Andrej Borsenkow
@ 1999-04-12  7:35   ` Geoff Wing
  0 siblings, 0 replies; 3+ messages in thread
From: Geoff Wing @ 1999-04-12  7:35 UTC (permalink / raw)
  To: zsh-workers

Andrej Borsenkow <borsenkow.msk@sni.de> typed:
:Yes, as I understand, it was changed in pws-14. It includes full description
:of subst rules in Parameters expansion section of manual.
:Basically, in quotes, the value of inner substitution is always forced to be
:scalar for outer substitution unless some flags or modifiers (notably, =,
:(@), (s)) prevent it.
:> % zsh-3.1.5-pws-14
:> % a=("${(f@)$(echo foo; echo bar)}"); print -l $a
:> foo
:> bar
:So, it is not a bug, it is by desing. There was a long thread here, where I
:tried to understand what ZSH substitution rules actually are. I admit (now
::-) that current state is more or less consistent. The problem is, it is
:near to impossible to explain difference between pws-14 and earlier versions
:because it is the first time these rules are explicitly stated.

OK, thanks, so in Misc/compctl-examples, we now have something like the
following and I can happily (yeah!) complete in cvs again:

cvsentries () {
        setopt localoptions nullglob unset
        if [[ -f ${pref}CVS/Entries ]]
        then
		reply=("${pref}${(@)^${(@)${(@)${(f)$(<${pref}CVS/Entries)}:#D*}#/}%%/*}")
        fi
}

-- 
Geoff Wing   <gcw@pobox.com>            Mobile : (Australia) 0412 162 441
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-04-12  7:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-10 11:28 BUG: zsh-3.1.5-pws-14: parameter expansion not working properly Geoff Wing
1999-04-12  6:51 ` Andrej Borsenkow
1999-04-12  7:35   ` Geoff Wing

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).