Bug
--posix does not actually reject the GNU i / I substitute flag.
The flag is silently accepted, which violates POSIX strictness when
the user opts into it.
Reproduction
$ echo a | /usr/bin/sed --posix 's/a/b/i'
sed: -e expression #1, char 7: unknown option to 's'
$ echo a | ./target/release/sed --posix 's/a/b/i'
b # silently honored, should be an error
What it should do
When --posix is set, all of the GNU substitute-flag extensions
(i, I, m, M, e) must be rejected with the same
"unknown option to 's'" wording style we already use for unknown flags.
--posix is already plumbed elsewhere (e.g. compiler.rs:1289 uses it
to choose the address-count of =), so the value is available.
Suspected place to add it
src/sed/compiler.rs:854 — compile_subst_flags. The function
already reaches a format!("invalid substitute flag: '{other}'")
branch around line 938. The fix is in the existing 'i' | 'I' =>
arm: when posix == true, fall through to the same error path.
'i' | 'I' => {
if posix {
return compilation_error( … "unknown option to 's'" );
}
subst.ignore_case = true;
line.advance();
}
Same treatment for m/M/e once those land (issues #9, #15).
Affected GNU testsuite tests
posix-mode-s (the for opt in i I m M ; loop at the top of the
script).
Bug
--posixdoes not actually reject the GNUi/Isubstitute flag.The flag is silently accepted, which violates POSIX strictness when
the user opts into it.
Reproduction
What it should do
When
--posixis set, all of the GNU substitute-flag extensions(
i,I,m,M,e) must be rejected with the same"unknown option to 's'" wording style we already use for unknown flags.
--posixis already plumbed elsewhere (e.g.compiler.rs:1289uses itto choose the address-count of
=), so the value is available.Suspected place to add it
src/sed/compiler.rs:854—compile_subst_flags. The functionalready reaches a
format!("invalid substitute flag: '{other}'")branch around line 938. The fix is in the existing
'i' | 'I' =>arm: when
posix == true, fall through to the same error path.Same treatment for
m/M/eonce those land (issues #9, #15).Affected GNU testsuite tests
posix-mode-s(thefor opt in i I m M ;loop at the top of thescript).