Hmm, it appears fish indeed does some tricky things with expansion. Separate
arguments are expanded left to right:
> set foo first
> echo $foo (set foo second) $foo (set foo third) $foo
first second third
>
But within one argument the command substitution is done first:
> set foo first
> echo $foo-(set foo second; echo)-$foo-(set foo third; echo)-$foo
third--third--third
>
Without the echo's inside the command substitutions the command gives an
empty line as output. Don't know if that's a bug or a feature. Does anyone
know if that's supposed to happen?
> set foo first
> echo $foo-(set foo second; echo)-$foo-(set foo third)-$foo
>
Jan
On Mon, Feb 21, 2011 at 08:39, Isaac Dupree
<m...@isaac.cedarswampstudios.org>wrote:
> On 02/19/11 12:45, weakish wrote:
> > In fish's user doc (section "Combining different expansions"):
> >
> >> When combining multiple parameter expansions, expansions are performed
> >> in the following order:
> >>
> >> * Command substitutions
> >> * Variable expansions
> >
> > So command substitutions get performed before variable expansions?
> >
> > But give fish the following code:
> >
> > echo $(echo HOME)
> >
> > fish said:
> >
> > echo $(echo HOME)
> > ^
> >
> > It seems variable expansion happens first here?
>
> Well, parsing happens first, and prevents the above (As it turns out, $
> can syntactically only accept literal variable names (and whatever else
> it specifically accepts)).
>
> (At least, that's how a sane shell might do it. I don't trust fish's
> parsing enough to be certain.)
>
> Anyway, command substitution and variable expension probably don't
> happen in a fixed order relative to each other. If you have (cat
> $variable) then the variable has to be expanded before the command is
> executed, obviously. On the other hand $SomeArray[(seq 3)] clearly has
> to execute the command before expanding the variable.
>
> -Isaac
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users