bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible bash bug when dealing with CR/LF in variable expansion


From: Paul Jarc
Subject: Re: Possible bash bug when dealing with CR/LF in variable expansion
Date: Tue, 24 Jan 2006 01:06:14 -0500
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux)

"Johannes Thoma" <johannes.thoma@gmx.at> wrote:
> johannes@entwicklung08:~/bash/bash-3.1$ zak=`printf '\x0d\x0a'`

As documented in the man page under "Command Substitution", this
strips off any trailing newlines from the program's output before
assigning the variable's value.  So zak contains only a carriage
return here.

> johannes@entwicklung08:~/bash/bash-3.1$ echo $zak | od -t x1
> 0000000 0d 0a
> 0000002

echo adds a newline at the end of its output.  Even if zak had a
newline, since it's unquoted, that newline would be removed.

> johannes@entwicklung08:~/bash/bash-3.1$ zak="${zak}karin"
> johannes@entwicklung08:~/bash/bash-3.1$ echo $zak | od -t x1
> 0000000 0d 6b 61 72 69 6e 0a
> 0000007

Again, the newline comes from echo, not from zak.


paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]