zsh-workers
 help / color / mirror / code / Atom feed
* Expansion bug?
@ 1995-07-06  9:36 Chris Hillery
  1995-07-07 16:44 ` Zoltan Hidvegi
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Hillery @ 1995-07-06  9:36 UTC (permalink / raw)
  To: zsh-workers


I don't recall seeing this mentioned before, although I've kind of
been skimming the list for some time.

In zsh2.6-beta1, I had the following statement:

  set -A cdpath $ROOT/{$PROJ,${(j:,:)PROJ_LIST}}/src

The part between braces expanded to a comma-separated list of $PROJ
and then the elements of the array $PROJ_LIST (which I turned into a
comma-separated list with the (j:,:) ).

This expanded via brace-expansion into a collection of paths like so:

 /root/project/src /root/a_proj/src /root/b_proj/src    etc.

However, when I upgraded to zsh2.6-beta10 recently, this broke. (I
hadn't upgraded between those two versions, so I'm not sure at exactly
which patch it went away.) Now it seems as though what's between the
braces gets turned into a two-element comma-separated list (even
though the second element DOES have commas in it). So I get:

 /root/project/src /root/a_proj,b_proj/src

I'm guessing that somewhere along the line the order of expansion got
inverted, so that the ${(j:,:)PROJ_LIST} doesn't get expanded until
after brace-expansion. But this does seem wrong to me - nested things
should be evaluated from the inside out.

-- 
Ceej
aka Chris Hillery
cjh@ebt.com


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

* Re: Expansion bug?
  1995-07-07 16:44 ` Zoltan Hidvegi
@ 1995-07-07  8:25   ` Chris Hillery
  1995-07-09 17:49     ` P.Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Hillery @ 1995-07-07  8:25 UTC (permalink / raw)
  To: hzoli; +Cc: zsh-workers


Zoltan replyeth:
> Chris Hillery <cjh@ebt.com> wrote:
> >   set -A cdpath $ROOT/{$PROJ,${(j:,:)PROJ_LIST}}/src
> > 
> > This expanded via brace-expansion into a collection of paths like so:
> > 
> >  /root/project/src /root/a_proj/src /root/b_proj/src    etc.
>
> The proper way to do this in recent zsh releases is
> 
> set -A cdpath $ROOT/{$PROJ,${^PROJ_LIST}}/src

Nope, unfortunately this doesn't work either - or rather, it works TOO
well. What happens in that case is that I get the value in PROJ
repeated in front of every value in $PROJ_LIST, so (using my above
example) cdpath turns into

  /root/project/src /root/proj_a/src /root/project/src /root/proj_b/src

Which, as it happens, actually works fine for a cdpath; it's just
redundant and inefficient. (And cdpath gets real huge real quick when
$PROJ_LIST has 10 entries...)

> However your original method probably still works if glob_subst is set (I
> haven't tried). There was a bugfix which changed that.

However, THIS works just fine - it returned the functionality I had in
beta1. So far this is the only way I've found to get the behaviour I
want, although Soren sent me mail showing how I could get almost the
same behaviour with rcexpandparam set (it worked with the simple
$ROOT/$PROJ_LIST/src case, and I had to manually prepend
$ROOT/$PROJ/src).

So, thanks... :)  (Hopefully globsubst won't have any other unwanted
side-effects...) 

> Cheers,
>    Zoltan

-- 
Ceej
aka Chris Hillery
cjh@ebt.com


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

* Re: Expansion bug?
  1995-07-06  9:36 Expansion bug? Chris Hillery
@ 1995-07-07 16:44 ` Zoltan Hidvegi
  1995-07-07  8:25   ` Chris Hillery
  0 siblings, 1 reply; 4+ messages in thread
From: Zoltan Hidvegi @ 1995-07-07 16:44 UTC (permalink / raw)
  To: Chris Hillery; +Cc: zsh-workers

Chris Hillery <cjh@ebt.com> wrote:
> 
> I don't recall seeing this mentioned before, although I've kind of
> been skimming the list for some time.
> 
> In zsh2.6-beta1, I had the following statement:
> 
>   set -A cdpath $ROOT/{$PROJ,${(j:,:)PROJ_LIST}}/src
> 
> The part between braces expanded to a comma-separated list of $PROJ
> and then the elements of the array $PROJ_LIST (which I turned into a
> comma-separated list with the (j:,:) ).
> 
> This expanded via brace-expansion into a collection of paths like so:
> 
>  /root/project/src /root/a_proj/src /root/b_proj/src    etc.
> 
> However, when I upgraded to zsh2.6-beta10 recently, this broke. (I

The proper way to do this in recent zsh releases is

set -A cdpatch $ROOT/{$PROJ,${^PROJ_LIST}}/src

However your original method probably still works if glob_subst is set (I
haven't tried). There was a bugfix which changed that. In early zsh versions
${(s:,:)foo} did not split foo at commas as this comma here become a comma
token which is not the same as a comma character. That's why your method
worked in early versions: brace expansion needs a comma token. And if
glob_subst is set, the result of substitution is tokenized.

Cheers,
   Zoltan


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

* Re: Expansion bug?
  1995-07-07  8:25   ` Chris Hillery
@ 1995-07-09 17:49     ` P.Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: P.Stephenson @ 1995-07-09 17:49 UTC (permalink / raw)
  To: Zsh hackers list

cjh@ebt.com wrote:
> > >   set -A cdpath $ROOT/{$PROJ,${(j:,:)PROJ_LIST}}/src
> > However your original method probably still works if glob_subst is set (I
> > haven't tried). There was a bugfix which changed that.
> 
> However, THIS works just fine...
> (Hopefully globsubst won't have any other unwanted
> side-effects...) 

You can get the complete effect without setting globsubst explicitly
by using the one-time flag ~ (works like ^):

set -A cdpath $ROOT/{$PROJ,${(j:,:)~PROJ_LIST}}/src

(although the word `grotesque' springs to mind unbidden).  This should
be virtually option-proof, but don't quote me.

-- 
Peter Stephenson <P.Stephenson@swansea.ac.uk>  Tel: +44 1792 205678 extn. 4461
WWW:  http://python.swan.ac.uk/~pypeters/      Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.


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

end of thread, other threads:[~1995-07-09 17:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-07-06  9:36 Expansion bug? Chris Hillery
1995-07-07 16:44 ` Zoltan Hidvegi
1995-07-07  8:25   ` Chris Hillery
1995-07-09 17:49     ` P.Stephenson

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).