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

Handling Double-quoted backslash



I'm not certain if this is a bug because many different shells handle
the case differently. I started testing double-quoted backslashes with
the newline character to see how the different shells handled the
following commands. I'm no expert, but based on what I've learned
about escaping
charcters, I would think TCSH is the only one that handles it
correctly. Is that not correct?

bash
eg@eg-laptop:~$ echo "a\nb"
a\nb
eg@eg-laptop:~$ echo "a\\nb"
a\nb
eg@eg-laptop:~$ echo "a\\\nb"
a\\nb

zsh
eg-laptop% echo "a\nb"
a
b
eg-laptop% echo "a\\nb"
a
b
eg-laptop% echo "a\\\nb"
a\nb

csh
% echo "a\nb"
a\nb
% echo "a\\nb"
a\\nb
% echo "a\\\nb"
a\\\nb

tcsh
eg-laptop:t> echo "a\nb"
a
b
eg-laptop:> echo "a\\nb"
a\nb
eg-laptop:> echo "a\\\nb"
a\
b

eg@eg-laptop:~/$ sh
$ echo "a\nb"
a
b
$ echo "a\\nb"
a
b
$ echo "a\\\nb"
a\nb


ksh shell
$ echo "a\nb"
a\nb
$ echo "a\\nb"
a\nb
$ echo "a\\\nb"
a\\nb

fish shell
eg@eg-laptop ~/t> echo "a\nb"
a\nb
eg@eg-laptop ~/> echo "a\\nb"
a\nb
eg@eg-laptop ~/> echo "a\\\nb"
a\\nb


eg@eg-laptop:~/wine-git$ psh
psh% echo "a\nb"
a
b
psh% echo "a\\nb"
a\
b
psh% echo "a\\\nb"
a\
b



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