From 7249fb7ec99aa0f839e4e60908ea9bc6bdb7d4a4 Mon Sep 17 00:00:00 2001 From: mukunda katta Date: Fri, 15 May 2026 08:06:48 -0700 Subject: [PATCH] fix: allow closing brace as command terminator --- src/sed/compiler.rs | 4 ++++ tests/by-util/test_sed.rs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/sed/compiler.rs b/src/sed/compiler.rs index bcfff31..36356a1 100644 --- a/src/sed/compiler.rs +++ b/src/sed/compiler.rs @@ -520,6 +520,10 @@ fn parse_command_ending( return Ok(()); } + if !line.eol() && line.current() == '}' { + return Ok(()); + } + if !line.eol() { return compilation_error( lines, diff --git a/tests/by-util/test_sed.rs b/tests/by-util/test_sed.rs index b31fed7..27ecae9 100644 --- a/tests/by-util/test_sed.rs +++ b/tests/by-util/test_sed.rs @@ -274,6 +274,17 @@ check_output!(addr_range_odd, ["-n", "1~2p", LINES1]); check_output!(addr_range_step_zero, ["-n", "10~0p", LINES1]); check_output!(addr_range_end_multiple, ["-n", "/l1_2/,~10p", LINES1]); +#[test] +fn command_may_end_before_closing_brace() { + for script in ["{p}", "1{p}", "/a/{p}"] { + new_ucmd!() + .arg(script) + .pipe_in("a\n") + .succeeds() + .stdout_is("a\na\n"); + } +} + //////////////////////////////////////////////////////////// // Substitution: s check_output!(subst_any, ["-e", r"s/./X/g", LINES1]);