Page MenuHomeFreeBSD

bin/sed: Implement long options for sed, add optional -Ii arguments
AbandonedPublic

Authored by eadler on Mar 31 2015, 5:09 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Sep 27, 3:11 PM
Unknown Object (File)
Tue, Sep 23, 9:41 PM
Unknown Object (File)
Thu, Sep 18, 6:15 AM
Unknown Object (File)
Wed, Sep 17, 8:42 AM
Unknown Object (File)
Mon, Sep 15, 7:14 AM
Unknown Object (File)
Sun, Sep 14, 10:37 AM
Unknown Object (File)
Sat, Sep 13, 8:41 AM
Unknown Object (File)
Sat, Sep 13, 1:16 AM
Subscribers

Details

Reviewers
jilles
antoine
pfg
adrian
bdrewery
Group Reviewers
manpages
Summary

Implement long options for the sed command

Also implement the GNU extension of permitting -I and -i to lack any extension at all

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage

Event Timeline

eadler retitled this revision from to bin/sed: Implement long options for sed, add optional -Ii arguments.
eadler updated this object.
eadler edited the test plan for this revision. (Show Details)
eadler added reviewers: jilles, adrian.

don't include bogus stuff

usr.bin/sed/main.c
135

The comment looks stray to me. Is there a missing --opt for it?

usr.bin/sed/main.c
135

there is no need for a longopt for it, since -E covers it. This comment explains why there is no longopt for it (in case someone tries to match every shortopt -> longopt).

I am scared, not about the implementation, but about backwards compatibility. If one needs the GNU extension there is the gnu sed port (and more that 30 ports depend on it), but if we need the traditional behavior, sed in base is the only option.

Apparently illumos didn't care much about it but perhaps there could be an environment variable that changes behavior to non gnu.

Please have an exp ports run on this.

In D2178#13, @pfg wrote:

I am scared, not about the implementation, but about backwards compatibility. If one needs the GNU extension there is the gnu sed port (and more that 30 ports depend on it), but if we need the traditional behavior, sed in base is the only option.

Apparently illumos didn't care much about it but perhaps there could be an environment variable that changes behavior to non gnu.

Please have an exp ports run on this.

This is a good point. Some configure script may try 'sed --file' (or any other flag) and then assume it is GNU Sed.

Eitan can you open a PR and assign to portmgr and set the exp-run flag on it?

This revision now requires changes to proceed.Apr 13 2015, 5:59 AM
eadler edited edge metadata.

remove optional -i param

eadler edited edge metadata.

actually do required argument

pfg edited edge metadata.

I haven't tested it but it looks good: I do prefer splitting the patch (and I was never a fan of the optional i).

BTW, we have advanced greatly in general compatibility. it would be good to see if we still need GNU sed on the 32 ports that require it currently.

jilles requested changes to this revision.Apr 17 2015, 4:19 PM
jilles edited edge metadata.

The man page and the usage message still contain optional arguments for -i and -I.

Making the argument to --in-place and --in-place-separate optional (possibly by making them independent from -i/-I from getopt_long's point of view) does not break compatibility and may be a good idea.

This revision now requires changes to proceed.Apr 17 2015, 4:19 PM
In D2178#30, @jilles wrote:

The man page and the usage message still contain optional arguments for -i and -I.

bah! I removed most of them, but forgot synopsis and usage

Making the argument to --in-place and --in-place-separate optional (possibly by making them independent from -i/-I from getopt_long's point of view) does not break compatibility and may be a good idea

I thought about this. I think we already break compat with GNU getopt by not having a separate --separate flag.

I may try and make the long options line up a bit more with GNU

eadler edited edge metadata.

version I tested

I built gmp and libdaemon: both of which build for me

usr.bin/sed/main.c
152

This change not only enables long options, but also options after non-option arguments. In some utilities such as units(1) we have turned that off with the "+".

usr.bin/sed/sed.1
77

This looks wrong: -a causes output files not to be truncated.

GNU sed does not support this, so we can devise our own long name.

99

When the option-argument is optional, the equals sign is required so that getopt_long() knows the option-argument is present.

Something like Fl -in-place-separate Ns Bo Ns = Ns Ar extension Bc seems to work.

The same thing applies to -i/--in-place below.