Bug
A closing brace } is not accepted as a command terminator. Idioms like
{p}, 1{p}, /re/{p} fail because the parser only accepts ; or
end-of-line after a command.
Reproduction
$ echo a | ./target/release/sed '{p}'
sed: <script argument 1>:1:3: error: extra characters at the end of the p command
$ echo a | ./target/release/sed '{p;}' # workaround: trailing semicolon
a
a
GNU sed 4.9:
$ echo a | /usr/bin/sed '{p}'
a
a
Suspected fix
src/sed/compiler.rs:514 — parse_command_ending:
fn parse_command_ending(
lines: &ScriptLineProvider,
line: &mut ScriptCharProvider,
cmd: &mut Command,
) -> UResult<()> {
if !line.eol() && line.current() == ';' {
line.advance();
return Ok(());
}
if !line.eol() {
return compilation_error( … "extra characters at the end of … command" );
}
Ok(())
}
Add a third accepted terminator: }. Crucially, do not advance past
it — leave it in the stream so that the outer loop's
compile_end_group_command (line 1300) can consume it as the block
close. Something like:
if !line.eol() && line.current() == '}' {
return Ok(());
}
before the existing extra characters error.
Affected GNU testsuite tests
compile-tests, compile-errors, and incidental in many others that
use {cmd} blocks.
Bug
A closing brace
}is not accepted as a command terminator. Idioms like{p},1{p},/re/{p}fail because the parser only accepts;orend-of-line after a command.
Reproduction
GNU sed 4.9:
Suspected fix
src/sed/compiler.rs:514—parse_command_ending:Add a third accepted terminator:
}. Crucially, do not advance pastit — leave it in the stream so that the outer loop's
compile_end_group_command(line 1300) can consume it as the blockclose. Something like:
before the existing
extra characterserror.Affected GNU testsuite tests
compile-tests,compile-errors, and incidental in many others thatuse
{cmd}blocks.