coreutils
[Top][All Lists]
Advanced

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

Re: /bin/echo -- $var


From: Ingo Krabbe
Subject: Re: /bin/echo -- $var
Date: Wed, 14 Aug 2019 15:45:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

echo is defunct by definition.

The preferred way is

printf %s\\n "data"

which is much more stable against such "attacks"!

Also it is far more stable to be used for multiline output:

printf %s\\n "line 1" line\ 2 'line 3' "line 5 and
line 6"

and no, it shouldn't. echo should not be used but must not be changed.

On 14/08/2019 14:01, Harald Dunkel wrote:
> Hi folks,
>
> I just learned by accident that
>
>       var="-n"
>       /bin/echo -- $var
>
> actually prints
>
>       -- -n
>
> Shouldn't it be just
>
>       -n
> ?
>
> Other tools in coreutils use '--' to indicate "stop parsing for
> command line flags", e.g. touch, ls and rm:
>
>       % /bin/touch -- -l
>       % /bin/ls -- -l
>       -l
>       % /bin/rm -- -l
>       % /bin/rm -- -l
>       /bin/rm: cannot remove '-l': No such file or directory
>
> Some common style would be nice here.
>
>
> Regards
> Harri
>



reply via email to

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