There's already an issue asking for a way to quote a process expansion, in 
order to a) ensure it's always treated as an argument in the surrounding 
context, and b) ensure it's treated as one argument instead of multiple.

In any case, you can do this today just by assigning the results of the process 
expansion to a variable and then quoting that in the command.

set -l inner (inner_expr)
outer_expr p1 "$inner" p2

-Kevin

On Jul 24, 2012, at 10:20 AM, Frank Fischer <[email protected]> 
wrote:

> On 2012-07-24, Frank Fischer wrote:
>> Hi,
>> 
>> I've recently discovered fish and am really impressed. But I have a
>> question concerning process expansion. Look at the follow examples
>> 
>> count (echo -n 1)     # shows 1
>> count (echo -n 1 2)   # shows 1
>> count (echo -n 1 2 3) # shows 1
>> count (echo -n)       # shows 0
>> 
>> I understand that in the first three lines the value of (...) is a
>> single string, thus a single parameter passed to count. In the last
>> example nothing is printed so nothing is passed count and its
>> parameter count is 0.
>> 
>> Now it happens that I have a situation where some command may return
>> either a non-empty string or nothing, i.e. an empty string. In this
>> situation I want the outer command being passed an empty argument
>> instead of nothing, i.e.
>> 
>> outer p1 (inner) p2
>> 
>> should call outer with three arguments in all cases, whether inner
>> returns an empty string or not. Is there an easy way to achieve this?
>> And wouldn't it make the whole command more reliable if one would know
>> that (inner) *always* returns exactly one argument?
> 
> Ok, I found out that simply adding a single final newline to the
> output of 'inner' ensures that always one argument is substituted.
> That final newline seems to be removed from the parameter before it is
> passed to 'outer'. I can really live with that convention (it makes
> perfectly sense to me).
> 
> Sorry for the noise,
> Frank
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Fish-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fish-users


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to