Excerpts from Alex Boisvert's message of 2014-06-25 02:27:17 +0200:
> Wanted to bring up an issue that I run into occasionally.
> I'll save the output of a command into a variable (array),
> % set foo (some command)
> Unfortunately, when I try to pipe `foo` into another command through `psub`:
> % command (echo $foo | psub)
> The newlines (\n) from the output of the original command are not passed-in
> ... a subtle change in content semantic.
that's because the newlines are discarded at () to allow passing an array as a
list of commandline arguments.
echo could maybe grow an option to seperate arguments by newline,
in the meantime maybe this helps:
function echonl
for i in $argv
echo $i
end
end
compare:
/> set foo (ls)
/> wc (echo $foo | psub)
1 35 264 /tmp/.psub.29424.6249
/> wc (echonl $foo | psub)
35 35 264 /tmp/.psub.29424.104
note that this even works like that in bash:
$ foo=`ls`
$ wc <(echo $foo)
1 35 264 /dev/fd/63
on command substitution, newlines are discarded.
greetings, martin.
--
eKita - the online platform for your entire academic life
--
chief engineer eKita.co
pike programmer pike.lysator.liu.se caudium.net societyserver.org
BLUG secretary beijinglug.org
foresight developer foresightlinux.org realss.com
unix sysadmin
Martin Bähr working in china http://societyserver.org/mbaehr/
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users