Re: /bin/echo -- $var

2019-08-15 Thread Stephane Chazelas
2019-08-15 07:29:37 -0700, Kaz Kylheku (Coreutils): > On 2019-08-15 00:53, Harald Dunkel wrote: > > IMHO they should have kept the "no args allowed" for echo > > ("in the late 70s") and should have introduced a new tool > > "eecho" instead. > > Well, new tool for printing was introduced under the

Re: /bin/echo -- $var

2019-08-15 Thread Eric Blake
On 8/15/19 2:36 AM, Harald Dunkel wrote: > On 8/14/19 3:10 PM, Eric Blake wrote: >> On 8/14/19 7:01 AM, Harald Dunkel wrote: >>> >>> Shouldn't it be just >>> >>> -n >> >> No, because 'echo' is one of the few exceptions to the rule, in that >> POSIX specifically mandates that it NOT recognize

Re: /bin/echo -- $var

2019-08-15 Thread Kaz Kylheku (Coreutils)
On 2019-08-15 00:53, Harald Dunkel wrote: IMHO they should have kept the "no args allowed" for echo ("in the late 70s") and should have introduced a new tool "eecho" instead. Well, new tool for printing was introduced under the name "printf".

Re: /bin/echo -- $var

2019-08-15 Thread Harald Dunkel
On 8/14/19 3:10 PM, Eric Blake wrote: On 8/14/19 7:01 AM, Harald Dunkel wrote: Shouldn't it be just -n No, because 'echo' is one of the few exceptions to the rule, in that POSIX specifically mandates that it NOT recognize -- as an end-of-options marker. But then the "-n" shouldn't

Re: /bin/echo -- $var

2019-08-15 Thread Harald Dunkel
On 8/14/19 10:23 PM, Stephane Chazelas wrote: 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

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