Page MenuHomeFreeBSD

rs: Use getopt() and strtol() instead of mannual parsing.
ClosedPublic

Authored by jhb on Sep 29 2022, 10:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 7, 12:28 PM
Unknown Object (File)
Feb 14 2024, 5:26 AM
Unknown Object (File)
Feb 14 2024, 5:17 AM
Unknown Object (File)
Feb 14 2024, 5:17 AM
Unknown Object (File)
Feb 14 2024, 4:58 AM
Unknown Object (File)
Dec 20 2023, 8:12 AM
Unknown Object (File)
Dec 12 2023, 10:51 AM
Unknown Object (File)
Sep 3 2023, 8:08 AM
Subscribers

Details

Summary

This uses the "::" extension to getopt() to handle options which take
an optional argument.

The updated flag tests were all wrong before and only passed because
the manual parser failed to raise errors when a required argument was
missing. The invalid argument test now gets a better error message.

In general the tests are pretty worthless. They don't actually test
any real functionality of the tool and provide a false sense that the
tests actually mean something.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Sep 29 2022, 10:48 PM

I will probably trim the last paragraph from the log since I ended up adding a followup commit to flesh out the tests more.

brooks added inline comments.
usr.bin/rs/rs.cc
422–432

It looks like these are dead code?

This revision is now accepted and ready to land.Sep 29 2022, 11:27 PM
emaste added inline comments.
usr.bin/rs/tests/rs_test.sh
103

these ones were actually buggy tests before?

usr.bin/rs/rs.cc
422–432

Yes, sorry. These options are not documented in the manpage and nothing uses the cord, icbd, or ocbd variables.

usr.bin/rs/tests/rs_test.sh
103

Yes. These should have been failing with an error due to missing a required argument.