This is mostly a curiosity question that arose here.
From the man page of GNU sed 4.8 I read
--posix
disable all GNU extensions.
so I understand that if a code like the following works, it means that -i
without argument is allowed by POSIX:
sed --posix -i -n '1,25p' *.txt
On the other hand, the same code (with or without --posix
) doesn't work for MacOS' BSD sed, because that version expects -i
to be followed by an argument.
I can see only two mutually exclusive possibilities:
--posix
option allows more than POSIX, which means it bugged and needs a bug reportWhat is the truth?
--posix
refers to the sed language itself, not the command line interface:
GNU sed includes several extensions to POSIX sed. In order to simplify writing portable scripts, this option disables all the extensions that this manual documents, including additional commands.
POSIX does not specify -i
, so an implementation without it can still be POSIX-conforming.