Implements the GNU `T LABEL` command: branch to LABEL if no s///
substitution has succeeded since the last input line was read or the
last t/T was taken. It is the inverse of `t` and shares the same
address and label parsing.
Wires 'T' into get_cmd_spec, resolve_branch_targets, and the processor
branch logic, resetting the substitution flag on evaluation just like
't'. Adds integration tests (simple branch + flag-clear) and a cmd-spec
unit test.
Closes#395
Co-authored-by: Diomidis Spinellis <dds@aueb.gr>
* chore: fix typo
* add: standalone e command
Implement the 'e' command. No argument implies execution of pattern space and any respective argument is to run with the output written to stream. Rejected under --posix and --sandbox.
Also stop silently swallowing shell stderr for e and s///e.
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* add: e command tests
Includes 17 new tests. Cover both forms of the new 'e' command: with-argument execution (including shell side effects, addressing, ';' not separating the argument, escape decoding, and backslash continuation) and the no-argument pattern-space form. Also cover --posix/--sandbox rejection and stderr surfacing on command failure.
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* chore: gate LF-related tests to UNIIX only
* address e command review
Validate shell output as utf-8 and error out instead of lossily converting it. Make CRLF strip conditionally compile to Windows only. Rename execute_pattern_as_shell to execute_pattern_as_shell_command. Add tests for non-utf-8 error paths.
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* add: Windows tests for e command with argument
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* fix: broken pipe race in sandbox e command test
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* Apply s/// p and e flags in written order
GNU sed applies the 'p' and 'e' substitution flags in the order they appear. 'pe' prints the pre-execution text then executes, while 'ep' executes then prints the result. Record whether 'p' precedes 'e' and apply them accordingly.
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
---------
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
The original Rust implementation assummed a UTF-8 environment, as is
common in modern systems. This commit improves GNU sed compatibility
by changing most processing to run on bytes rather than Rust's Unicode
characters and strings. This change also improves the handling of binary
files. The commit adds a simple POSIX-compatible locale configuration
to support UTF-8 processing when specified. While at it, also fix
script-specified file handling to take place through OsString and
add a few missing unit tests.
The change fixes two failing GNU test suite cases.