Bug
The GNU z command — clear the pattern space (sets it to empty
without printing) — is not implemented.
Reproduction
$ printf "a\nb\n" | /usr/bin/sed 'z'
# two empty lines
$ printf "a\nb\n" | ./target/release/sed 'z'
sed: <script argument 1>:1:1: error: invalid command code `z'
What it should do
From the GNU manual:
z This command empties the contents of the pattern space.
Equivalent to s/.*// but never sets the substitution flag (so does
not affect t/T). Takes 0 or 1 address; rejected under --posix.
Suspected place to add it
src/sed/compiler.rs:1276 — get_cmd_spec:
'z' => Ok(CommandSpec {
n_addr: 2,
handler: compile_empty_command,
}),
…and in processor.rs add an execution case that does
pattern_space.clear() (or equivalent for the type used).
Note: not to be confused with the -z / --null-data CLI flag, which
is already implemented at mod.rs:106.
Affected GNU testsuite tests
Direct test (z.sh) is not in the runner's set, but compile-errors
asserts that z is rejected under --posix. Once z exists,
bad_command rejection works automatically.
Bug
The GNU
zcommand — clear the pattern space (sets it to emptywithout printing) — is not implemented.
Reproduction
What it should do
From the GNU manual:
Equivalent to
s/.*//but never sets the substitution flag (so doesnot affect
t/T). Takes 0 or 1 address; rejected under--posix.Suspected place to add it
src/sed/compiler.rs:1276—get_cmd_spec:…and in
processor.rsadd an execution case that doespattern_space.clear()(or equivalent for the type used).Note: not to be confused with the
-z/--null-dataCLI flag, whichis already implemented at
mod.rs:106.Affected GNU testsuite tests
Direct test (
z.sh) is not in the runner's set, butcompile-errorsasserts that
zis rejected under--posix. Oncezexists,bad_commandrejection works automatically.