Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Turn on, tune up, rock out." -- Billy Gibbons


devel / comp.unix.programmer / Re: on the current openbsd echo.c

SubjectAuthor
* on the current openbsd echo.cMeredith Montgomery
+* Re: on the current openbsd echo.cJohn McCue
|`* Re: on the current openbsd echo.cMeredith Montgomery
| `- Re: on the current openbsd echo.cMeredith Montgomery
+* Re: on the current openbsd echo.cRainer Weikusat
|`* Re: on the current openbsd echo.cMeredith Montgomery
| `* Re: on the current openbsd echo.cRainer Weikusat
|  `* Re: on the current openbsd echo.cMeredith Montgomery
|   `- Re: on the current openbsd echo.cRainer Weikusat
`* Re: on the current openbsd echo.cKaz Kylheku
 +* Re: on the current openbsd echo.cKeith Thompson
 |+* Re: on the current openbsd echo.cKeith Thompson
 ||`- Re: on the current openbsd echo.cMeredith Montgomery
 |`- Re: on the current openbsd echo.cRainer Weikusat
 `- Re: on the current openbsd echo.cGeoff Clare

1
on the current openbsd echo.c

<86sfvli741.fsf@levado.to>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16862&group=comp.unix.programmer#16862

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!aioe.org!5BnS/cjNJzCZUkjqfOlcKw.user.46.165.242.75.POSTED!not-for-mail
From: mmontgomery@levado.to (Meredith Montgomery)
Newsgroups: comp.unix.programmer
Subject: on the current openbsd echo.c
Date: Wed, 24 Nov 2021 18:19:58 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86sfvli741.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="15841"; posting-host="5BnS/cjNJzCZUkjqfOlcKw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:05J3Q7OfFcT+f3Tz/ZbQSB9VGzM=
 by: Meredith Montgomery - Wed, 24 Nov 2021 21:19 UTC

This is odd. I had seen the echo.c from some BSD system in the past. I
don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
was OpenBSD because OpenBSD's source still behaves I remember it.
Here's the behavior.

%echo -n -n hello
hello%

Notice that the -n seems to have been processed twice, which is why we
don't see a -n. However, that's not the behavior you find when you
interpret its source code at

https://cvsweb.openbsd.org/src/bin/echo/echo.c

I've looked at all revisions there. They're all essentially the same.
The behavior written in C in the URL above is essentially this:

%./openbsd-echo -n -n hello
-n hello%

So, what's up with that?

I remember this well because when I read it for the first time, there
was a loop looking for -n, which prompted me to ask --- omg, how am I
going to print ``-n'' to the terminal? A friend eventually gave me a
nice solution. I also recall Brian Kernighan discussing this problem in
the UNIX Programming Environment as his solution was equally nice, but
different. This must mean that Brian Kernighan was also aware of
echo-programs with such behavior and so my memory is not really failing
me.

Re: on the current openbsd echo.c

<snmcsn$mdc$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16863&group=comp.unix.programmer#16863

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jmccue@fuzzball.mhome.org (John McCue)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Wed, 24 Nov 2021 22:04:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <snmcsn$mdc$1@dont-email.me>
References: <86sfvli741.fsf@levado.to>
Reply-To: jmclnx@SPAMisBADgmail.com
Injection-Date: Wed, 24 Nov 2021 22:04:07 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ce424dfef27f9b75f35eebc18a929007";
logging-data="22956"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QKgJgLus8IngBZXC+b5Y1"
User-Agent: tin/2.4.4-20191224 ("Millburn") (OpenBSD/7.0 (amd64))
Cancel-Lock: sha1:O1NZW7IRI8Q63s0PMS9AYMMtjg0=
X-OS-Version: OpenBSD 7.0 amd64
 by: John McCue - Wed, 24 Nov 2021 22:04 UTC

Meredith Montgomery <mmontgomery@levado.to> wrote:
> This is odd. I had seen the echo.c from some BSD system in the past. I
> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
> was OpenBSD because OpenBSD's source still behaves I remember it.
> Here's the behavior.
>
> %echo -n -n hello
> hello%
>
<snip>

> I've looked at all revisions there. They're all essentially the same.
> The behavior written in C in the URL above is essentially this:
>
> %./openbsd-echo -n -n hello
> -n hello%
>
> So, what's up with that?

/bin/echo and builtins with csh(1), tcsh(1)and ksh(1)
on OpenBSD prints:
-n hello

Are you sure it was not some builtin from another or older
shell ?

<snip>

--
csh(1) - "An elegant shell, for a more... civilized age."
- Paraphrasing Star Wars

Re: on the current openbsd echo.c

<87k0gx196a.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16864&group=comp.unix.programmer#16864

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweikusat@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Wed, 24 Nov 2021 22:27:25 +0000
Lines: 20
Message-ID: <87k0gx196a.fsf@doppelsaurus.mobileactivedefense.com>
References: <86sfvli741.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net 6BWxweLcnSSox3QMqiaSpQ11iIR6kKAj5MNgcvoYIXTU18Yd8=
Cancel-Lock: sha1:vuVQFGK7jX17LFKuoMCBnbTILOQ= sha1:ig+hsTj+lA5EFg2mGO706UVV3fw=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
 by: Rainer Weikusat - Wed, 24 Nov 2021 22:27 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:
> This is odd. I had seen the echo.c from some BSD system in the past. I
> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
> was OpenBSD because OpenBSD's source still behaves I remember it.
> Here's the behavior.
>
> %echo -n -n hello
> hello%

[...]

Both the GNU /bin/echo and the bash builtin also behave in this way. The
(d)ash one doesn't.

> I remember this well because when I read it for the first time, there
> was a loop looking for -n, which prompted me to ask --- omg, how am I
> going to print ``-n'' to the terminal?

The solution to this is usually 'use printf(1)' which behaves in a sane
way.

Re: on the current openbsd echo.c

<86a6hqj2po.fsf@levado.to>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16877&group=comp.unix.programmer#16877

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!aioe.org!Ebt/NY2VQgZs9eKba7C1cA.user.46.165.242.75.POSTED!not-for-mail
From: mmontgomery@levado.to (Meredith Montgomery)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Fri, 26 Nov 2021 13:34:11 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86a6hqj2po.fsf@levado.to>
References: <86sfvli741.fsf@levado.to>
<87k0gx196a.fsf@doppelsaurus.mobileactivedefense.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="53807"; posting-host="Ebt/NY2VQgZs9eKba7C1cA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:XuQvalM052BxkGEJrjko/5slXfk=
 by: Meredith Montgomery - Fri, 26 Nov 2021 16:34 UTC

Rainer Weikusat <rweikusat@talktalk.net> writes:

> Meredith Montgomery <mmontgomery@levado.to> writes:
>> This is odd. I had seen the echo.c from some BSD system in the past. I
>> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
>> was OpenBSD because OpenBSD's source still behaves I remember it.
>> Here's the behavior.
>>
>> %echo -n -n hello
>> hello%
>
> [...]
>
> Both the GNU /bin/echo and the bash builtin also behave in this way. The
> (d)ash one doesn't.

I guess /bin/sh on OpenBSD does as well. I've been fooled thinking I
was running /bin/echo when I was running ``builtin echo'' of /bin/sh on
OpenBSD.

>> I remember this well because when I read it for the first time, there
>> was a loop looking for -n, which prompted me to ask --- omg, how am I
>> going to print ``-n'' to the terminal?
>
> The solution to this is usually 'use printf(1)' which behaves in a sane
> way.

Indeed. Much better.

Why would anyone do an echo program like that? Where they initially
thinking that they would support lots of flags and therefore parse the
entire argv?

Re: on the current openbsd echo.c

<87a6hqd7zl.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16878&group=comp.unix.programmer#16878

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweikusat@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Fri, 26 Nov 2021 19:36:46 +0000
Lines: 47
Message-ID: <87a6hqd7zl.fsf@doppelsaurus.mobileactivedefense.com>
References: <86sfvli741.fsf@levado.to>
<87k0gx196a.fsf@doppelsaurus.mobileactivedefense.com>
<86a6hqj2po.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net EivOf2hbj2e4LKavN229qAOEevve8Jsh/xq0I825+t43dSFqw=
Cancel-Lock: sha1:HiQwi+PBqHHaKEXCFETW1cPiaPE= sha1:GTnIEsMprAvgqROsXZA3Pif8yJQ=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
 by: Rainer Weikusat - Fri, 26 Nov 2021 19:36 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:
> Rainer Weikusat <rweikusat@talktalk.net> writes:
>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>> This is odd. I had seen the echo.c from some BSD system in the past. I
>>> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
>>> was OpenBSD because OpenBSD's source still behaves I remember it.
>>> Here's the behavior.
>>>
>>> %echo -n -n hello
>>> hello%
>>
>> [...]
>>
>> Both the GNU /bin/echo and the bash builtin also behave in this way. The
>> (d)ash one doesn't.

[...]

> Why would anyone do an echo program like that? Where they initially
> thinking that they would support lots of flags and therefore parse the
> entire argv?

Compatibility with existing code, most likely. Judging from comments in
the GNU echo.c, they were aiming for compatibility with the /bin/sh
builtin echo of V9 Research UNIX said to be distributed as part of
SysV.

Apart from that, that's the usual convention: Silently process any number of
repeated options. For boolean options, that's not going to change
anything. OTOH, one has to handle this situation somehow and this
approach is easy to implement and semantically perfectly reasonable
(enabling something that's already enabled is a harmles nop). The issue
with the GNU echo.c is really just that they do their own option parsing
(ie, they don't use getopt) and don't follow the usual
convention of using -- to denote the end of the option list.

Eg,

[rw@doppelsaurus]~#printf -n
bash: printf: -n: invalid option
printf: usage: printf [-v var] format [arguments]

but

[rw@doppelsaurus]~#printf -- -n
-n[rw@doppelsaurus]~#

Re: on the current openbsd echo.c

<86y25ahbqk.fsf@levado.to>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16879&group=comp.unix.programmer#16879

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!aioe.org!Ebt/NY2VQgZs9eKba7C1cA.user.46.165.242.75.POSTED!not-for-mail
From: mmontgomery@levado.to (Meredith Montgomery)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Fri, 26 Nov 2021 18:02:11 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86y25ahbqk.fsf@levado.to>
References: <86sfvli741.fsf@levado.to> <snmcsn$mdc$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="46681"; posting-host="Ebt/NY2VQgZs9eKba7C1cA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:fEzj0fibYpNpN5YCW7y6bQYt8a0=
 by: Meredith Montgomery - Fri, 26 Nov 2021 21:02 UTC

John McCue <jmccue@fuzzball.mhome.org> writes:

> Meredith Montgomery <mmontgomery@levado.to> wrote:
>> This is odd. I had seen the echo.c from some BSD system in the past. I
>> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
>> was OpenBSD because OpenBSD's source still behaves I remember it.
>> Here's the behavior.
>>
>> %echo -n -n hello
>> hello%
>>
> <snip>
>
>> I've looked at all revisions there. They're all essentially the same.
>> The behavior written in C in the URL above is essentially this:
>>
>> %./openbsd-echo -n -n hello
>> -n hello%
>>
>> So, what's up with that?
>
> /bin/echo and builtins with csh(1), tcsh(1)and ksh(1)
> on OpenBSD prints:
> -n hello
>
> Are you sure it was not some builtin from another or older
> shell ?

It was a builtin. I was totally fooled by it. For years because for
years I've been thinking that some BSD echo was weird. I'm curious now
as to why GNU echo loops through argv. (The only thing I can think of
is that it was plans for the future --- new flags and so on. But POSIX
requires only -n and as a first argument --- IIRC.)

Re: on the current openbsd echo.c

<86o866hbj8.fsf@levado.to>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16880&group=comp.unix.programmer#16880

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!aioe.org!Ebt/NY2VQgZs9eKba7C1cA.user.46.165.242.75.POSTED!not-for-mail
From: mmontgomery@levado.to (Meredith Montgomery)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Fri, 26 Nov 2021 18:06:35 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86o866hbj8.fsf@levado.to>
References: <86sfvli741.fsf@levado.to> <snmcsn$mdc$1@dont-email.me>
<86y25ahbqk.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="50697"; posting-host="Ebt/NY2VQgZs9eKba7C1cA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:rNoT9be1n8AfRWXHw/W3dWV+D7Y=
 by: Meredith Montgomery - Fri, 26 Nov 2021 21:06 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:

> John McCue <jmccue@fuzzball.mhome.org> writes:
>
>> Meredith Montgomery <mmontgomery@levado.to> wrote:
>>> This is odd. I had seen the echo.c from some BSD system in the past. I
>>> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
>>> was OpenBSD because OpenBSD's source still behaves I remember it.
>>> Here's the behavior.
>>>
>>> %echo -n -n hello
>>> hello%
>>>
>> <snip>
>>
>>> I've looked at all revisions there. They're all essentially the same.
>>> The behavior written in C in the URL above is essentially this:
>>>
>>> %./openbsd-echo -n -n hello
>>> -n hello%
>>>
>>> So, what's up with that?
>>
>> /bin/echo and builtins with csh(1), tcsh(1)and ksh(1)
>> on OpenBSD prints:
>> -n hello
>>
>> Are you sure it was not some builtin from another or older
>> shell ?
>
> It was a builtin. I was totally fooled by it. For years because for
> years I've been thinking that some BSD echo was weird. I'm curious now
> as to why GNU echo loops through argv. (The only thing I can think of
> is that it was plans for the future --- new flags and so on. But POSIX
> requires only -n and as a first argument --- IIRC.)

I did not recall correctly. The -n as a first argument is
implementation-defined. ``If the first operand is -n, or if any of the
operands contain a <backslash> character, the results are
implementation-defined.'' -- IEEE Std 1003.1-2017

Re: on the current openbsd echo.c

<86h7byhbgm.fsf@levado.to>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16881&group=comp.unix.programmer#16881

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!aioe.org!Ebt/NY2VQgZs9eKba7C1cA.user.46.165.242.75.POSTED!not-for-mail
From: mmontgomery@levado.to (Meredith Montgomery)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Fri, 26 Nov 2021 18:08:09 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86h7byhbgm.fsf@levado.to>
References: <86sfvli741.fsf@levado.to>
<87k0gx196a.fsf@doppelsaurus.mobileactivedefense.com>
<86a6hqj2po.fsf@levado.to>
<87a6hqd7zl.fsf@doppelsaurus.mobileactivedefense.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="50697"; posting-host="Ebt/NY2VQgZs9eKba7C1cA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Cancel-Lock: sha1:1NclUE4RiCYRK2zqONkUCW1HVBA=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Meredith Montgomery - Fri, 26 Nov 2021 21:08 UTC

Rainer Weikusat <rweikusat@talktalk.net> writes:

> Meredith Montgomery <mmontgomery@levado.to> writes:
>> Rainer Weikusat <rweikusat@talktalk.net> writes:
>>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>>> This is odd. I had seen the echo.c from some BSD system in the past. I
>>>> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
>>>> was OpenBSD because OpenBSD's source still behaves I remember it.
>>>> Here's the behavior.
>>>>
>>>> %echo -n -n hello
>>>> hello%
>>>
>>> [...]
>>>
>>> Both the GNU /bin/echo and the bash builtin also behave in this way. The
>>> (d)ash one doesn't.
>
> [...]
>
>> Why would anyone do an echo program like that? Where they initially
>> thinking that they would support lots of flags and therefore parse the
>> entire argv?
>
> Compatibility with existing code, most likely. Judging from comments in
> the GNU echo.c, they were aiming for compatibility with the /bin/sh
> builtin echo of V9 Research UNIX said to be distributed as part of
> SysV.

Thank you!

> Apart from that, that's the usual convention: Silently process any number of
> repeated options. For boolean options, that's not going to change
> anything. OTOH, one has to handle this situation somehow and this
> approach is easy to implement and semantically perfectly reasonable
> (enabling something that's already enabled is a harmles nop). The issue
> with the GNU echo.c is really just that they do their own option parsing
> (ie, they don't use getopt) and don't follow the usual
> convention of using -- to denote the end of the option list.

Yes, most likely because of POSIX? Or should I say ``IEEE Std 1003.1-2017''?

--8<---------------cut here---------------start------------->8---
The echo utility shall not recognize the "--" argument in the manner
specified by Guideline 10 of XBD Utility Syntax Guidelines; "--" shall
be recognized as a string operand.

Implementations shall not support any options.
--8<---------------cut here---------------end--------------->8---

> Eg,
>
> [rw@doppelsaurus]~#printf -n
> bash: printf: -n: invalid option
> printf: usage: printf [-v var] format [arguments]
>
> but
>
>
> [rw@doppelsaurus]~#printf -- -n
> -n[rw@doppelsaurus]~#

Thank you!

Re: on the current openbsd echo.c

<87a6ho815i.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16896&group=comp.unix.programmer#16896

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweikusat@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Sun, 28 Nov 2021 20:40:09 +0000
Lines: 31
Message-ID: <87a6ho815i.fsf@doppelsaurus.mobileactivedefense.com>
References: <86sfvli741.fsf@levado.to>
<87k0gx196a.fsf@doppelsaurus.mobileactivedefense.com>
<86a6hqj2po.fsf@levado.to>
<87a6hqd7zl.fsf@doppelsaurus.mobileactivedefense.com>
<86h7byhbgm.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net f1SCmstdfWSTqp5MsYdyRA77mA1kVkgdMHWr3qCyPWHeqh2mg=
Cancel-Lock: sha1:3okVh7uJyWPmht5jscyvgVctLfU= sha1:KCLpGBC1e7qUVCjvsz+7zaHuGoo=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
 by: Rainer Weikusat - Sun, 28 Nov 2021 20:40 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:
> Rainer Weikusat <rweikusat@talktalk.net> writes:

[...]

>> The issue with the GNU echo.c is really just that they do their own
>> option parsing (ie, they don't use getopt) and don't follow the usual
>> convention of using -- to denote the end of the option list.
>
> Yes, most likely because of POSIX? Or should I say ``IEEE Std 1003.1-2017''?
>
> The echo utility shall not recognize the "--" argument in the manner
> specified by Guideline 10 of XBD Utility Syntax Guidelines; "--" shall
> be recognized as a string operand.
>
> Implementations shall not support any options.

That's a bit of a moot point as the GNU echo isn't compliant with this,
anyway: They suppport -E, -e and -n as options if nothing else starting
with a hyphen was found on the command-line before it, eg,

rw@brushfire:~/work/cadaptSuricataRulesUpdate$ echo -a -n
-a -n

and they don't support escape sequences unless POSIXLY_CORRECT was set
in the environment or either -e or -E appeared on the command-line while
the program was still looking for options.

Compatibility with SysV quirks may have been a worthwhile feature in the
1990s, but nowadays, pretty much nothing but echoes of its quirks in
other software remains from it.

Re: on the current openbsd echo.c

<20211130091012.922@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16914&group=comp.unix.programmer#16914

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-1380@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Tue, 30 Nov 2021 17:19:29 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <20211130091012.922@kylheku.com>
References: <86sfvli741.fsf@levado.to>
Injection-Date: Tue, 30 Nov 2021 17:19:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9ee16b5229fb530a47dcfcff595d5844";
logging-data="21479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zyxbFBgfR6FskzHaPjJ5pWNlboRcKgTs="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:dxx4e+1zalsAv6X2L+owWtJResY=
 by: Kaz Kylheku - Tue, 30 Nov 2021 17:19 UTC

On 2021-11-24, Meredith Montgomery <mmontgomery@levado.to> wrote:
> This is odd. I had seen the echo.c from some BSD system in the past. I
> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
> was OpenBSD because OpenBSD's source still behaves I remember it.
> Here's the behavior.
>
> %echo -n -n hello
> hello%

According to POSIX, echo doesn't take any options, including the --
option to end options. See here:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html

The echo utility shall not recognize the "--" argument in the manner
specified by Guideline 10 of XBD Utility Syntax Guidelines; "--" shall
be recognized as a string operand.

Implementations shall not support any options.

Thus, "echo -n -n hello" is required to print "-n -n hello".

echo -n is a GNU-ism that deviates from the spec.

> I remember this well because when I read it for the first time, there
> was a loop looking for -n, which prompted me to ask --- omg, how am I
> going to print ``-n'' to the terminal?

Without a newline?

printf %s -n

printf is not forbidden from taking options (though POSIX doesn't
describe any), so another way would require the use of -- so -n doesn't
look like an option.

printf -- -n

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: on the current openbsd echo.c

<87k0gpfg9z.fsf@nosuchdomain.example.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16915&group=comp.unix.programmer#16915

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Tue, 30 Nov 2021 14:08:24 -0800
Organization: None to speak of
Lines: 39
Message-ID: <87k0gpfg9z.fsf@nosuchdomain.example.com>
References: <86sfvli741.fsf@levado.to> <20211130091012.922@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="8326e5ee14eeeeead64e673e1ed1971f";
logging-data="22986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//gVhr6xko+ZYk9bGL4V2F"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:G/pAknPSxCbZ9XveCjEhwC4ViVk=
sha1:PcgTDSCTBctvwUq24yMe2ZJQoek=
 by: Keith Thompson - Tue, 30 Nov 2021 22:08 UTC

Kaz Kylheku <480-992-1380@kylheku.com> writes:
> On 2021-11-24, Meredith Montgomery <mmontgomery@levado.to> wrote:
>> This is odd. I had seen the echo.c from some BSD system in the past. I
>> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
>> was OpenBSD because OpenBSD's source still behaves I remember it.
>> Here's the behavior.
>>
>> %echo -n -n hello
>> hello%
>
> According to POSIX, echo doesn't take any options, including the --
> option to end options. See here:
>
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
>
> The echo utility shall not recognize the "--" argument in the manner
> specified by Guideline 10 of XBD Utility Syntax Guidelines; "--" shall
> be recognized as a string operand.
>
> Implementations shall not support any options.
>
> Thus, "echo -n -n hello" is required to print "-n -n hello".
>
> echo -n is a GNU-ism that deviates from the spec.

Do we know where the -n option originated? It exists in a number of
different implementations of echo, not just GNU. My guess is that GNU
wasn't the origin.

Note that there are at least two GNU implementations of echo, the echo
command provided by the coreutils package and the builtin echo command
provided by GNU bash.

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: on the current openbsd echo.c

<87fsrdffkx.fsf@nosuchdomain.example.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16916&group=comp.unix.programmer#16916

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Tue, 30 Nov 2021 14:23:26 -0800
Organization: None to speak of
Lines: 58
Message-ID: <87fsrdffkx.fsf@nosuchdomain.example.com>
References: <86sfvli741.fsf@levado.to> <20211130091012.922@kylheku.com>
<87k0gpfg9z.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="8326e5ee14eeeeead64e673e1ed1971f";
logging-data="22986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WSBDBe9rTI84BEyBkDKrf"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:sPwD2cRgtVF79efkDEywbYJ5AOk=
sha1:oSkSJXLmK0beuxWs0droYhQs/Z8=
 by: Keith Thompson - Tue, 30 Nov 2021 22:23 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Kaz Kylheku <480-992-1380@kylheku.com> writes:
>> On 2021-11-24, Meredith Montgomery <mmontgomery@levado.to> wrote:
>>> This is odd. I had seen the echo.c from some BSD system in the past. I
>>> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
>>> was OpenBSD because OpenBSD's source still behaves I remember it.
>>> Here's the behavior.
>>>
>>> %echo -n -n hello
>>> hello%
>>
>> According to POSIX, echo doesn't take any options, including the --
>> option to end options. See here:
>>
>> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
>>
>> The echo utility shall not recognize the "--" argument in the manner
>> specified by Guideline 10 of XBD Utility Syntax Guidelines; "--" shall
>> be recognized as a string operand.
>>
>> Implementations shall not support any options.
>>
>> Thus, "echo -n -n hello" is required to print "-n -n hello".
>>
>> echo -n is a GNU-ism that deviates from the spec.
>
> Do we know where the -n option originated? It exists in a number of
> different implementations of echo, not just GNU. My guess is that GNU
> wasn't the origin.
>
> Note that there are at least two GNU implementations of echo, the echo
> command provided by the coreutils package and the builtin echo command
> provided by GNU bash.
>
> [...]

I found some more information here:
https://en.wikipedia.org/wiki/Echo_(command)#History

echo began within Multics. After it was programmed in C by Doug
McIlroy as a "finger exercise" and proved to be useful, it became
part of Version 2 Unix. echo -n in Version 7 replaced prompt, (which
behaved like echo but without terminating its output with a line
delimiter).

On PWB/UNIX and later Unix System III, echo started expanding C
escape sequences such as \n with the notable difference that octal
escape sequences were expressed as \0ooo instead of \ooo in C.

Eighth Edition Unix echo only did the escape expansion when passed a
-e option, and that behaviour was copied by a few other
implementations such as the builtin echo command of Bash or zsh and
GNU echo.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: on the current openbsd echo.c

<86o861161d.fsf@levado.to>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16920&group=comp.unix.programmer#16920

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!aioe.org!Hfy7oSiPJvgOJpfwzvj4dw.user.46.165.242.75.POSTED!not-for-mail
From: mmontgomery@levado.to (Meredith Montgomery)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Tue, 30 Nov 2021 22:13:18 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86o861161d.fsf@levado.to>
References: <86sfvli741.fsf@levado.to> <20211130091012.922@kylheku.com>
<87k0gpfg9z.fsf@nosuchdomain.example.com>
<87fsrdffkx.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="15005"; posting-host="Hfy7oSiPJvgOJpfwzvj4dw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:R6UtGQALTtlKGP+Y0jMwfaRhInE=
 by: Meredith Montgomery - Wed, 1 Dec 2021 01:13 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Kaz Kylheku <480-992-1380@kylheku.com> writes:
>>> On 2021-11-24, Meredith Montgomery <mmontgomery@levado.to> wrote:
>>>> This is odd. I had seen the echo.c from some BSD system in the past. I
>>>> don't recall which it was --- OpenBSD, FreeBSD, NetBSD. But I think it
>>>> was OpenBSD because OpenBSD's source still behaves I remember it.
>>>> Here's the behavior.
>>>>
>>>> %echo -n -n hello
>>>> hello%
>>>
>>> According to POSIX, echo doesn't take any options, including the --
>>> option to end options. See here:
>>>
>>> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
>>>
>>> The echo utility shall not recognize the "--" argument in the manner
>>> specified by Guideline 10 of XBD Utility Syntax Guidelines; "--" shall
>>> be recognized as a string operand.
>>>
>>> Implementations shall not support any options.
>>>
>>> Thus, "echo -n -n hello" is required to print "-n -n hello".
>>>
>>> echo -n is a GNU-ism that deviates from the spec.
>>
>> Do we know where the -n option originated? It exists in a number of
>> different implementations of echo, not just GNU. My guess is that GNU
>> wasn't the origin.
>>
>> Note that there are at least two GNU implementations of echo, the echo
>> command provided by the coreutils package and the builtin echo command
>> provided by GNU bash.
>>
>> [...]
>
> I found some more information here:
> https://en.wikipedia.org/wiki/Echo_(command)#History

Nice. Thanks for sharing.

> echo began within Multics. After it was programmed in C by Doug
> McIlroy as a "finger exercise" and proved to be useful, it became
> part of Version 2 Unix. echo -n in Version 7 replaced prompt, (which
> behaved like echo but without terminating its output with a line
> delimiter).

The -n is a nice addition, I think.

> On PWB/UNIX and later Unix System III, echo started expanding C
> escape sequences such as \n with the notable difference that octal
> escape sequences were expressed as \0ooo instead of \ooo in C.

Now I think they should've changed the name. :-)

[...]

Re: on the current openbsd echo.c

<15ak7i-fb6.ln1@ID-313840.user.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16926&group=comp.unix.programmer#16926

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: geoff@clare.See-My-Signature.invalid (Geoff Clare)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Wed, 1 Dec 2021 13:32:49 +0000
Lines: 39
Message-ID: <15ak7i-fb6.ln1@ID-313840.user.individual.net>
References: <86sfvli741.fsf@levado.to> <20211130091012.922@kylheku.com>
Reply-To: netnews@gclare.org.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net hO9b9cidi6y6/hguUFreyAX7c7Jpa49VITClgIlC3vLYC8Le+t
X-Orig-Path: ID-313840.user.individual.net!not-for-mail
Cancel-Lock: sha1:e2dVucoqMj/U7QCgcHVbBwXHeVg=
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
 by: Geoff Clare - Wed, 1 Dec 2021 13:32 UTC

Kaz Kylheku wrote:

> According to POSIX, echo doesn't take any options, including the --
> option to end options. See here:
>
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
>
> The echo utility shall not recognize the "--" argument in the manner
> specified by Guideline 10 of XBD Utility Syntax Guidelines; "--" shall
> be recognized as a string operand.
>
> Implementations shall not support any options.
>
> Thus, "echo -n -n hello" is required to print "-n -n hello".

That doesn't follow. The requirement that echo does not support any
options, and that "--" is not special, just mean that all of the
arguments are required to be treated as operands. The echo OPERANDS
section in POSIX says this:

The following operands shall be supported:

string
A string to be written to standard output. If the first
operand is -n, or if any of the operands contain a <backslash>
character, the results are implementation-defined.

(It then goes on to specify XSI requirements that include treating
a first operand of -n as a string to be output, and special treatment
of backslash escapes.)

> echo -n is a GNU-ism that deviates from the spec.

No, it's allowed for non-XSI echo implementations.

However, "echo -- -n hello" is required to print "-- -n hello".

--
Geoff Clare <netnews@gclare.org.uk>

Re: on the current openbsd echo.c

<87fsrc5jfx.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16927&group=comp.unix.programmer#16927

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweikusat@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: on the current openbsd echo.c
Date: Wed, 01 Dec 2021 17:22:26 +0000
Lines: 10
Message-ID: <87fsrc5jfx.fsf@doppelsaurus.mobileactivedefense.com>
References: <86sfvli741.fsf@levado.to> <20211130091012.922@kylheku.com>
<87k0gpfg9z.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net IwMb0IugaG2xOgXBeMBI0wFm3miQl9OtcNQtX9jSJ1TlP3Aog=
Cancel-Lock: sha1:6cOYVYJkL83P23TVzOSz28ARDc8= sha1:bH0MfO4DO7ROJ0h3UG2eoZ3cVos=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
 by: Rainer Weikusat - Wed, 1 Dec 2021 17:22 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

[...]

> Note that there are at least two GNU implementations of echo, the echo
> command provided by the coreutils package and the builtin echo command
> provided by GNU bash.

Judging from comments in the code, the former is a GNU-internal fork of
the latter.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor