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

Re: bug in zsh-2.6-beta21



Vincent Lefevre (Vincent.Lefevre@xxxxxxxxxxxxxxx) wrote:
> This is OK. But under zsh 2.6-beta21:
> 
> $ var=`echo "ab\ncd\nef"`
> $ echo $var
> ab
> cd
> ef
> $ var=`echo "ab\ncd\nef\n"`
> $ echo $var
> ab
> cd
> ef
> $
> 
> The last "\n" is not printed.

I think this is good behaviour sh, ksh and bash also strip trailing
newlines. It should maybe be documented in the manual. E.g. bash
manual states:
              $(command)
       or
              `command`
       Bash performs  the  expansion  by  executing  command  and
       replacing  the command substitution with the standard out-
       put of the command, with any trailing newlines deleted.

Whereas zsh manual says:
       A  command  enclosed  in  parentheses preceded by a dollar
       sign, like so: $(...) or quoted with grave accents:  `...`
       is replaced with its standard output.  If the substitution
       is not enclosed in double quotes,  the  output  is  broken
       into  words  using  the  IFS  parameter.  The substitution

Removing trailing newlines is *not* specifically mentioned.

-- 
hniksic@xxxxxxx              |  Student of electrical engineering
hniksic@xxxxxxxxxxxxx        |  University of Zagreb, Croatia
------------------------------------------------------------------
`VI' - An editor used by those heretics that don't subscribe to
       the Emacs religion.




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