A couple of relevant issues on github:
https://github.com/fish-shell/fish-shell/issues/1656
https://github.com/fish-shell/fish-shell/issues/159
The problem: can't capture command substitution output with newlines intact
$ set out (seq 5)
> $ echo "$out"
> 1 2 3 4 5
To do it properly, we need to reset IFS to the empty string
$ set oldIFS "$IFS"
> $ set IFS ""
> $ set out (seq 5)
> $ echo "$out"
> 1
> 2
> 3
> 4
> 5
> $ set IFS "$oldIFS"
To do it improperly, append a newline to each list element. You still get
space-separated elements, and you get an extra newline at the end:
$ set out {(seq 5)}\n
> $ echo "$out"
> 1
> 2
> 3
> 4
> 5
> $
On Thu, Mar 26, 2015 at 5:54 AM, Elias Assmann <elias.assm...@gmail.com>
wrote:
> Hi Fishers,
>
> In fish, command substitution returns a list when the command outputs
> multiple lines, like this:
>
> > function foo; echo $argv[1]; end
> > foo (echo a; echo b; echo c)
> a
>
> But what do you do when you need the output as one word? (Where, in
> Other Shells, you might do ‘foo "$(echo a; echo b; echo c)"’.)
>
>
> Here's the problem that leads me to ask this: I wanted to tell
> subversion to ignore all files present in my directory that are not
> already under version control. This command gets me a list of those files:
>
> > alias svnlist "svn st | grep '\?' | tr -s ' ' | cut -d ' ' -f 2"
>
> It outputs one file per line, which is just the format that the
> ‘svn:ignore’ property expects. But this
>
> > svn ps svn:ignore (svnlist) .
>
> fails because the property value must be a single word. On the other
> hand, this
>
> > svn ps svn:ignore (svnlist | tr '\n' ' ') .
>
> as well as this
>
> > set tmp (svnlist); svn ps svn:ignore "$tmp" .
>
> does not work because it puts all the files on one line.
>
>
> In the present case you can use ‘svn propset’s --file option, either
> with standard input
>
> > svnlist | svn ps svn:ignore -F - .
>
> or in combination with ‘psub’. One of these workarounds is likely to
> work in many cases. But still, is there a way to capture the exact
> output of a command?
>
>
> Elias
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
--
*Glenn Jackman*
Senior Software Developer
*Pythian - Love your data*
jack...@pythian.com
Tel: +1 613 565 8696 Ext. 1478
Mobile: +1 613 808 4984
www.pythian.com
--
--
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users