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

Reply via email to