Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Word splitting with command substitution



% echo $(head -n 2 /etc/passwd)
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh

% contents=$(head -n 2 /etc/passwd)
% echo $contents
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh

Why does the second example give me two separate lines, while the
first is joined into one line? The zshexpn man page says that
unquoted command substitutions are split into words, so I would
think the first case is correct, but why does the second case work
as it does?

-- 
A new dinette set!



Messages sorted by: Reverse Date, Date, Thread, Author