Page MenuHomeFreeBSD

rc.d/dumpon: minor hardening/tightening up
ClosedPublic

Authored by ngie on Sat, Jun 27, 6:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jul 20, 10:01 AM
Unknown Object (File)
Mon, Jul 20, 8:52 AM
Unknown Object (File)
Sun, Jul 19, 9:30 AM
Unknown Object (File)
Mon, Jul 6, 12:34 AM
Unknown Object (File)
Sun, Jul 5, 5:36 AM
Unknown Object (File)
Fri, Jul 3, 1:12 AM
Unknown Object (File)
Thu, Jul 2, 11:50 PM
Unknown Object (File)
Thu, Jul 2, 10:26 PM
Subscribers

Details

Summary
  • Scope local variables properly to each function.
  • Quote variables that should be treated as single words.
  • Replace ${cmd}; if [ $? -eq 0 ] with if ${cmd} for simplicity.

MFC after: 1 week

Test Plan

The script continues to function as part of boot and when called on demand.

Diff Detail

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

Event Timeline

ngie requested review of this revision.Sat, Jun 27, 6:34 AM

This conflicts with https://reviews.freebsd.org/D34518 which was recently touched.

libexec/rc/rc.d/dumpon
42

If you're adding quotes, it makes sense to add them here since splitting need not happen twice.

56

These quotes do not affect anything; while it may be useful to add them for consistency, I don't think it makes much sense if other parts are left unquoted but do not need splitting even though splitting is not expected.

64

If you're adding quotes, it makes sense to add them here since $? is not supposed to be split.

71

These quotes do not affect anything either.

102

If you're adding quotes, it makes sense to add them here since this is not supposed to be split.

libexec/rc/rc.d/dumpon
38
42

I thin @ngie's intention is to add quotes that are necessary for correctness, and these are not since splitting has already occurred so $flag will not be split further.

53
64

$? can never be anything other than an integer, so quotes are not needed for correctness.

102

We know that $name is a single word and will not be split.

ngie added inline comments.
libexec/rc/rc.d/dumpon
38

๐Ÿ‘

42

Yes. Excellent point though @jilles -- I can do that.

53

๐Ÿ‘

56

These quotes do not affect anything; while it may be useful to add them for consistency, I don't think it makes much sense if other parts are left unquoted but do not need splitting even though splitting is not expected.

Will revert the change.

64

I agree with @des : quoting a builtin variable seems like incorrect pedanticness (unless I'm missing something about how this variable is set).

71

These quotes do not affect anything either.

Will revert this change.

102

We know that $name is a single word and will not be split.

I'll take @jilles's suggestion: it's a best practice to quote here, and I know a lot of engineers who copy examples verbatim without understanding the subtlety of how things like this work.

ngie marked 9 inline comments as done.Wed, Jul 15, 1:02 AM
ngie marked an inline comment as done.
This revision was not accepted when it landed; it landed in state Needs Review.Thu, Jul 16, 4:25 PM
This revision was automatically updated to reflect the committed changes.