On Mon, Feb 21, 2011 at 13:59, Martin Bähr <
mba...@email.archlab.tuwien.ac.at> wrote:

> On Mon, Feb 21, 2011 at 11:35:09AM +0100, Jan Kanis wrote:
> > > 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
>
> one of the interesting things about command substitution is that it can
> return a list and will be expanded accordingly, consider returning two
> lines:
>
> > echo start-(echo foo; echo bar)-stop
> start-foo-stop start-bar-stop
>
> so naturally, if the command returns 0 lines, the surounding string
> will be expanded 0 times.
>
> greetings, martin.
>

But fish variables are also lists - e.g. after ``set foo``, $foo is the
empty list and by similar logic the command wouldn't have to be expanded...
I dimly recall Axel explaining that commands are expanded in a separate pass
so they won't have to be run many times (because commands can be expensive
and/or have side effects).

-- 
Beni Cherniavsky-Paskin <c...@users.sf.net>
------------------------------------------------------------------------------
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

Reply via email to