On Thu, Sep 15, 2011 at 11:18:16PM +0200, Jan Kanis wrote:
>  <elided>
>  AFAIK fish has no syntax to say "use the result of this command as a single
>  argument". Did I miss anything on this?

No. I'm pretty sure you have the right understanding.

>  <elided>
>  - Is there syntax that I missed that does this?

Not that I'm aware of.

>  - If not, do we need any? I think it is an important feature to be able to
>  handle special characters in any output
>  - What kind of syntax would do?

I'm not sure a new syntax is the ideal fix here, although it's a
possible one. The real 'evil' is the array handling itself. For example:

> echo 1 2\n3\n\n4
1 2
3

4
> set -l var (echo 1 2\n3\n\n4)
> set | grep \^var
var '1 2'  '3'  ''  '4'
> echo $var
1 2 3  4
> echo "$var"
1 2 3  4

Notice how fish handily split the resulting string at newlines into
separate array elements, and then expanded the result using spaces.
For the typical case of processing data from line-oriented utilities
like sed, this is exactly what you do /not/ want, as the simple act of
storing data into a variable and retrieving it changes the data.

You may be wondering what the point of the last two echo commands are.
For the first, fish expands $var to "'1 2' '3' '' '4'", which echo then
happily prints, while for the second, fish formats to "1 2 3  4" first.
The first form can usually be handled with xargs (although this ideally
wouldn't be necessary), but the second is broken any way I look at it.

However, because there's no sane way to pipe the data to xargs (you
weren't thinking of using echo, were you?) after retrieving it from a
variable, you're reduced to the annoying hack you thought up earlier.
Well, unless you decided to forego variables and instead dump everything
into temporary files and use xargs -a ...


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to