hi gerrit,

mmm... isn't the echo command an external command?...

whereis echo
echo: /bin/echo /usr/share/man/man1/echo.1.gz
/usr/share/man/man3/echo.3ncurses.gz

.. should behave the same on different shells, right?

i still went and tested your sugestion on my lenny, which gave me also
diferent results for bash and dash...

#bash:
read line && printf "%s\n" "$line"
\\ \\ \\ \\
\ \ \ \

read -r line && printf "%s\n" "$line"
\\ \\ \\ \\
\\ \\ \\ \\

#dash:
read line && printf "%s\n" "$line"
\\ \\ \\ \\
\\\\

read -r line && printf "%s\n" "$line"
\\ \\ \\ \\
\\ \\ \\ \\

if the debian default shell is now dash (afaik)
this makes existing scripts unreliable and prone to error... right?

best wishes
  rui

On 4 May 2010 17:04, Gerrit Pape <p...@smarden.org> wrote:

> On Wed, Mar 10, 2010 at 11:02:15AM +0000, Rui Damas wrote:
> > the bellow examples explain it:
> >
> > #bash:
> > $ read line && echo $line
> > \\ \\ \\ \\
> > \ \ \ \
> >
> > $ read -r line && echo "$line"
> > \\ \\
> > \\ \\
> >
> > #dash:
> > $ read line && echo "$line"
> > \\ \\ \\ \\
> > \\
> >
> > $ read -r line && echo "$line"
> > \\ \\
> > \ \
>
> Hi Rui,
>
> it's the 'echo "$line"' that recognizes the backslash, not 'read -r',
> see
>
>  http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html
>
> Please try
>
> dash -c 'read -r line && printf "%s\n" "$line"' <<\EOT
> \\ \\
> EOT
>
> Regards, Gerrit.
>

Reply via email to