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)
Sat, Nov 23, 12:45 PM
Unknown Object (File)
Thu, Nov 21, 2:04 PM
Unknown Object (File)
Thu, Nov 21, 12:10 PM
Unknown Object (File)
Thu, Nov 14, 3:02 AM
Unknown Object (File)
Thu, Nov 7, 6:10 AM
Unknown Object (File)
Tue, Oct 29, 3:49 PM
Unknown Object (File)
Oct 20 2024, 11:11 PM
Unknown Object (File)
Oct 16 2024, 4:56 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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

usr.bin/sed/main.c
199 ↗(On Diff #69553)

There has to be at least one input file specified.

245 ↗(On Diff #69553)

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 ↗(On Diff #69553)

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 ↗(On Diff #69553)

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 ↗(On Diff #69553)

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.