🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.folklore.computers
Article #932

Re: Portability of 'echo -n'

#932
From: Nuno Silva
Date: Sun, 08 Nov 2026 00:25
43 lines
3364 bytes
On 2026-11-07, Waldek Hebisch wrote:

> Nuno Silva <nunojsilva@invalid.invalid> wrote:
>> On 2026-11-07, Lawrence D’Oliveiro wrote:
>> 
>>> On Fri, 6 Nov 2026 21:52:32 -0000 (UTC), Waldek Hebisch wrote:
>>>
>>>> Supressing newline in echo is used by quite a lot of shell scripts
>>>> and the '-n' option is normal way to do this on Linux.
>>>
>>> As on every other *nix that uses the GNU userland utilities.
>>>
>>> I really cannot imagine anybody wanting a command environment that did
>>> not interpret “-n” in this way ...
>> 
>> It is non-standard, and that has implications for portability. However
>> convenient that "-n" option may be where present, is there really a
>> reason not to use something more portable and conformant? IEEE
>> 1003.1-2008 suggests printf (84381–84383).
>
> Recently I had displeasure to use 'printf' in a Makefile, in my
> setup that lead to orgy of quoting.  Comparing, cases when
> 'echo -n' were enough were much simpler.
>
> 'echo -n' is standard, AFAIK it is GNU standard and compatible
> with Posix.

'echo -n' is standard if it prints "-n" followed by a newline.

    «The echo utility writes its arguments to standard output, followed
    by a <newline>. If there are no arguments, only the <newline> is
    written.» -- POSIX (2008 again, lines 84298–84299)

> It seems that only Unix compliance disallows it.
> Given long history, widespread use and utility there should be
> very strong reason to disallow it.  I am not aware of such a
> reason.

It seems to me that widespread use and long history *is* the very strong
reason not to allow or require it.

-- 
Nuno Silva
Technical Details
Message-ID: <11cofi8$3t49f$3@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11bujmd$31udl$1@dont-email.me> <qg3prm-ql7.ln1@ID-313840.user.individual.net> <11cdgp6$46jl$5@dont-email.me> <fcqrrm-5o6.ln1@ID-313840.user.individual.net> <11cg8q2$12d33$1@dont-email.me> <eceurm-lq4.ln1@ID-313840.user.individual.net> <11cijp9$1sunb$1@dont-email.me> <n231sm-d23.ln1@ID-313840.user.individual.net> <11ckp2g$2jqjg$2@dont-email.me> <11cl5im$2nftp$3@dont-email.me> <11cli6u$2u21d$1@paganini.bofh.team> <11clrnu$3188f$1@dont-email.me> <11cmsv6$3a9pr$2@dont-email.me> <11co4v2$37o9q$2@paganini.bofh.team>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Nuno Silva <nunojsilva@invalid.invalid>
Newsgroups: alt.folklore.computers
Subject: Re: Portability of 'echo -n'
Date: Sun, 08 Nov 2026 00:25:44 +0000
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <11cofi8$3t49f$3@dont-email.me>
References: <11bujmd$31udl$1@dont-email.me>
	<qg3prm-ql7.ln1@ID-313840.user.individual.net>
	<11cdgp6$46jl$5@dont-email.me>
	<fcqrrm-5o6.ln1@ID-313840.user.individual.net>
	<11cg8q2$12d33$1@dont-email.me>
	<eceurm-lq4.ln1@ID-313840.user.individual.net>
	<11cijp9$1sunb$1@dont-email.me>
	<n231sm-d23.ln1@ID-313840.user.individual.net>
	<11ckp2g$2jqjg$2@dont-email.me> <11cl5im$2nftp$3@dont-email.me>
	<11cli6u$2u21d$1@paganini.bofh.team> <11clrnu$3188f$1@dont-email.me>
	<11cmsv6$3a9pr$2@dont-email.me> <11co4v2$37o9q$2@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 08 Nov 2026 00:25:45 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="4100399"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+BH0CdQvkNpp7fMYPhuMaM"; posting-host="9071713fc3249a668ad5a4c961bfcfc1"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Cancel-Lock: sha1:k7jGhIbdp33E2UU8pfbJKhwuhaE= sha256:xoUhCzhxVIlrFe1Xgr6i/ZhHJUGmdDVKp7N5vBGrC7A=
	sha1:uTbqXJqv55bfG0OHGwC9UMV4vpw= sha256:0H4RBsMaOtiqKcLxPR1NfRkLU3chQ+r6XPMGRfSHRUk=