bug-bash
[Top][All Lists]
Advanced

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

echo backslash


From: Kenneth M. Howlett
Subject: echo backslash
Date: Sat, 14 Sep 2002 09:41:54 -0400 (EDT)

Bash seems to behave oddly when I try to echo a backslash:

echo a\bc\z  # displays   abcz
echo a\\bc\\z  # displays   a\bc\z
echo a\\\\bc\\\\z  # displays   a\\bc\\z
echo "a\bc\z"  # displays   a\bc\z
echo "a\\bc\\z"  # displays   a\bc\z
echo "a\\\\bc\\\\z"  # displays   a\\bc\\z
echo -e a\bc\z  # displays   abcz
echo -e a\\bc\\z  # displays   c\z
echo -e a\\\\bc\\\\z  # displays   a\bc\z
echo -e "a\bc\z"  # displays   c\z
echo -e "a\\bc\\z"  # displays   c\z
echo -e "a\\\\bc\\\\z"  # displays   a\bc\z

You will probably say this is not a bug. But I think this
behavior is illogical and inconsistent.

I do not think bash should drop the backslash in 'echo a\b'. If
backslash substitution is not being done, the backslash should
be treated as an ordinary character.

In 'echo "a\b\\"', backslash substitution is
done for '\\', but not for '\b'. This is inconsistent.

In 'echo -e "a\\bc\\\\"', backslash substitution is done twice.

I think 'echo a\b' and 'echo "a\b"' should produce the same result.

I am running redhat linux 7.2 with kernel 2.4.19 on an i386.
My bash version is:
GNU bash, version 2.05.8(1)-release (i386-redhat-linux-gnu)





reply via email to

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