enhancementgood first issue
Repository metrics
- Stars
- (91 stars)
- PR merge metrics
- (PR metrics pending)
説明
Bug
The GNU F command — print the current input filename, followed by a
newline — is not implemented.
Reproduction
$ echo abc | /usr/bin/sed -n 'F' /etc/hostname
/etc/hostname
$ echo abc | ./target/release/sed -n 'F' /etc/hostname
sed: <script argument 1>:1:1: error: invalid command code `F'
What it should do
From GNU sed manual:
FPrint out the file name of the current input file (with a trailing newline).
Behaviour notes:
- Output goes to stdout (like
=,p). - For stdin, GNU prints
-. - Honors
-z(NUL-separated output) — seenulldata.sh. - Accepts an address range like other GNU extensions.
- Rejected under
--posix(already handled by the existingbad_command(OPT)path; onceFis added, the--posixrejection test incompile-errorswill keep working as expected).
Suspected place to add it
src/sed/compiler.rs:1276 — get_cmd_spec:
'F' => Ok(CommandSpec {
n_addr: 2,
handler: compile_empty_command, // F takes no args
}),
…plus a corresponding execution case in src/sed/processor.rs (search
for the match cmd.code near processor.rs:635). The processor
already has access to the current input filename via the same path that
-i uses to compute backup names — see src/sed/in_place.rs for how
filenames are tracked.
Affected GNU testsuite tests
follow-symlinks, nulldata. Also unblocks the F parts of
follow-symlinks-stdin.