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:
- GNU sed's
--posixoption allows more than POSIX, which means it bugged and needs a bug report - BSD sed is not POSIX-compliant.
What is the truth?
--posixrefers to the sed language itself, not the command line interface:POSIX does not specify
-i, so an implementation without it can still be POSIX-conforming.