[Top][All Lists]

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

Re: echo "-e" produces no outputs

From: Stephane CHAZELAS
Subject: Re: echo "-e" produces no outputs
Date: Fri, 17 Jul 2009 20:03:25 +0000 (UTC)
User-agent: slrn/pre1.0.0-11 (Linux)

2009-07-17, 13:09(-06), Eric Blake:
> According to Huang Tao on 7/17/2009 9:46 AM:
>> I'm not sure whether it is a bug
>> how can i echo the text string "-e" barely ( or "-n", "-E")
>> i tried
>> $echo "-e"
>> $echo '-e'
>> and some other inputs, all of which produced no outputs.
> Instead of using echo (which POSIX itself admits is fraught with
> portability problems), use printf:
> printf -- '-e\n'

Note that it's a known non POSIX-conformance of bash.

POSIX is explicit that

echo -e

Should output "-e\n".

With bash, you can do it with:

echo -ne '-e\n'


echo -n '-e

None of which is POSIX (the behavior being unspecified in both
cases), so the advise of using printf is certainly a good one
for portability.


reply via email to

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