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)
Oct 11 2024, 10:20 PM
Unknown Object (File)
Oct 3 2024, 6:28 PM
Unknown Object (File)
Oct 2 2024, 5:27 AM
Unknown Object (File)
Sep 30 2024, 11:21 PM
Unknown Object (File)
Sep 27 2024, 12:02 PM
Unknown Object (File)
Sep 26 2024, 11:09 PM
Unknown Object (File)
Sep 21 2024, 3:18 AM
Unknown Object (File)
Sep 18 2024, 12:34 PM
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.