Re: /bin/echo -- $var

2019-08-14 Thread Stephane Chazelas
2019-08-14 09:28:22 -0700, Kaz Kylheku (Coreutils): [...] > According to POSIX, echo doesn't take options. It is specified > that "Implementations shall not support any options." > (We have options, though, so things are complicated.) [...] The POSIX specification of "echo" is going to change in

Re: /bin/echo -- $var

2019-08-14 Thread Kaz Kylheku (Coreutils)
On 2019-08-14 05: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 ? According to POSIX, echo doesn't take options. It is specified that "Implementations shall not

Re: /bin/echo -- $var

2019-08-14 Thread Ingo Krabbe
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

Re: /bin/echo -- $var

2019-08-14 Thread Eric Blake
On 8/14/19 7:01 AM, Harald Dunkel wrote: > Hi folks, > > I just learned by accident that > > var="-n" > /bin/echo -- $var > > actually prints > > -- -n Correct. This is the POSIX-mandated behavior. > > Shouldn't it be just > > -n No, because 'echo' is one of the

/bin/echo -- $var

2019-08-14 Thread Harald Dunkel
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