🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #394

POSIX: printf ---?

#394
From: Christian Weisgerber
Date: Tue, 17 Nov 2026 17:43
27 lines
1669 bytes
Any POSIX lawyers around?

Various printf(1) implementations attempt option parsing on the first
argument and choke on something like "printf ---":

FreeBSD sh(1) builtin:  printf: Illegal option --
FreeBSD standalone:     printf: illegal option -- -
bash(1) builtin:        -bash: printf: --: invalid option

POSIX does not specify any options for printf(1).

The workaround is to explicitly terminate option parsing with "--",
i.e., "printf -- ---".  That works at least across OpenBSD, FreeBSD,
GNU coreutils and bash.  But does it conform to POSIX?


The problem isn't hypothetical.  In release 0.131, Game of Tree's
regression test suite added things like

+       printf '--- gamma/delta\t\n' >> $testroot/stdout.expected
+       printf '+++ gamma/delta\t\n' >> $testroot/stdout.expected

which promptly blew up on FreeBSD and presumably some flavors of
Linux.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de
Technical Details
Message-ID: <slrn11fp4hu.sql.naddy@lorvorc.mips.inka.de>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: Christian Weisgerber <naddy@mips.inka.de>
Newsgroups: comp.unix.shell
Subject: POSIX: printf ---?
Date: Tue, 17 Nov 2026 17:43:26 -0000 (UTC)
Message-ID: <slrn11fp4hu.sql.naddy@lorvorc.mips.inka.de>
Injection-Date: Tue, 17 Nov 2026 17:43:26 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
	logging-data="29526"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/pre1.0.4-9 (FreeBSD)