uutils/sed

Add `T` command (branch on no-substitution)

Open

#395 opened on Apr 30, 2026

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Rust (23 forks)github user discovery
enhancementgood first issue

Repository metrics

Stars
 (91 stars)
PR merge metrics
 (PR metrics pending)

Description

Bug

The GNU T command — branch to label if no s/// substitution has been performed since the last input line was read — is not implemented. It is the inverse of t.

Reproduction

$ echo a | /usr/bin/sed -n 'Tend; p; :end'
a

$ echo a | ./target/release/sed -n 'Tend; p; :end'
sed: <script argument 1>:1:1: error: invalid command code `T'

What it should do

From the GNU manual:

T LABEL If no s/// has done a successful substitution since the last input line was read or branch was taken, branch to LABEL.

Same address/parsing rules as t. Already-implemented t lives in compile_label_command (compiler.rs:1308); T should be parsed by the same handler.

Suspected place to add it

src/sed/compiler.rs:1276get_cmd_spec:

'b' | 't' | 'T' => Ok(CommandSpec {
    n_addr: 2,
    handler: compile_label_command,
}),

…then in the execution side (look near the t handler in processor.rs), branch when the substitution flag is false instead of true, and clear it the same way t does.

Affected GNU testsuite tests

Indirect — the broader compile-tests/compile-errors suites assert that T is rejected under --posix and accepted otherwise.

Contributor guide