Page MenuHomeFreeBSD

Read commands from stdin when -f - is passed to sed(1)
ClosedPublic

Authored by 0mp on Mar 15 2020, 10:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 19 2024, 11:38 AM
Unknown Object (File)
Feb 19 2024, 11:38 AM
Unknown Object (File)
Feb 19 2024, 11:38 AM
Unknown Object (File)
Dec 20 2023, 4:03 AM
Unknown Object (File)
Dec 12 2023, 4:00 AM
Unknown Object (File)
Nov 12 2023, 4:36 PM
Unknown Object (File)
Jun 29 2023, 6:53 AM
Unknown Object (File)
Jun 29 2023, 6:50 AM
Subscribers

Details

Summary
Read commands from stdin when -f - is passed to sed(1)

This patch teaches sed to interpret the a file name of "-" in
a special way when given to the -f flag. 

This behavior is present in GNU sed.

PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=244872

Test Plan
  • make check

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 30060
Build 27871: arc lint + arc unit

Event Timeline

usr.bin/sed/main.c
199

There has to be at least one input file specified.

245

I am not sure if it makes any difference if I try to avoid depending on the presence of /dev/stdin by using the 0th descriptor here instead.

247

Is stdin name here alright? Perhaps it could be changed to -?

0mp retitled this revision from Read commands from stdin when -f - are passed to sed(1) to Read commands from stdin when -f - is passed to sed(1).Mar 16 2020, 3:48 PM
0mp edited the summary of this revision. (Show Details)

LGTM, but I have no time to test.
Note that this type of changes should be checked with an exxp-run

In D24079#529828, @pfg wrote:

LGTM, but I have no time to test.
Note that this type of changes should be checked with an exxp-run

Thanks! I'll open a PR on bugzilla for that.

tobik added inline comments.
usr.bin/sed/main.c
245–246

Can this not just be f = stdin?

Do not open stdin again.

0mp marked an inline comment as done.Mar 18 2020, 1:57 PM
0mp added inline comments.
usr.bin/sed/main.c
245–246

Good catch! The tests are still passing.

0mp marked an inline comment as done.

Rebase

In D24079#529828, @pfg wrote:

LGTM, but I have no time to test.
Note that this type of changes should be checked with an exxp-run

Exp-run seems fine: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=244872#c3

This revision is now accepted and ready to land.Jun 7 2020, 2:52 PM
This revision was automatically updated to reflect the committed changes.