Skip to content

Commit 7249fb7

Browse files
committed
fix: allow closing brace as command terminator
1 parent f083fa0 commit 7249fb7

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/sed/compiler.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,10 @@ fn parse_command_ending(
520520
return Ok(());
521521
}
522522

523+
if !line.eol() && line.current() == '}' {
524+
return Ok(());
525+
}
526+
523527
if !line.eol() {
524528
return compilation_error(
525529
lines,

tests/by-util/test_sed.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,17 @@ check_output!(addr_range_odd, ["-n", "1~2p", LINES1]);
274274
check_output!(addr_range_step_zero, ["-n", "10~0p", LINES1]);
275275
check_output!(addr_range_end_multiple, ["-n", "/l1_2/,~10p", LINES1]);
276276

277+
#[test]
278+
fn command_may_end_before_closing_brace() {
279+
for script in ["{p}", "1{p}", "/a/{p}"] {
280+
new_ucmd!()
281+
.arg(script)
282+
.pipe_in("a\n")
283+
.succeeds()
284+
.stdout_is("a\na\n");
285+
}
286+
}
287+
277288
////////////////////////////////////////////////////////////
278289
// Substitution: s
279290
check_output!(subst_any, ["-e", r"s/./X/g", LINES1]);

0 commit comments

Comments
 (0)