Page MenuHomeFreeBSD

Fix some shell issues in etcupdate.sh
Needs ReviewPublic

Authored by bcr on Jun 19 2023, 2:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 30 2024, 6:41 PM
Unknown Object (File)
Apr 30 2024, 6:41 PM
Unknown Object (File)
Apr 30 2024, 6:41 PM
Unknown Object (File)
Apr 30 2024, 4:14 PM
Unknown Object (File)
Dec 22 2023, 3:21 AM
Unknown Object (File)
Dec 20 2023, 2:55 AM
Unknown Object (File)
Aug 20 2023, 2:53 PM
Unknown Object (File)
Aug 16 2023, 4:51 AM

Details

Reviewers
jhb
Group Reviewers
Src Committers
Summary

This patch does the following:

  • Adds double quotes around variables to prevent globbing and word splitting, see SC2086
  • Prefers $() over backticks in most cases, see SC2006
  • Uses Use [ -n .. ] instead of ! [ -z .. ] logic, see SC2237
Test Plan
  1. Apply patch to /usr.sbin/etcupdate
  2. Check output or results when running it

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

bcr requested review of this revision.Jun 19 2023, 2:06 PM
usr.sbin/etcupdate/etcupdate.sh
149

Surely quoting the whole root arg with one set of quotes?

"${DESTDIR}/root$1"

193โ€“194

Same here: quote the entire arg

206โ€“207

And here. May need ${1}

215

And here

228

And here and more below

Alright, I can provide a diff that does that. Makes it easier to read. I'll update this revision when it's ready.

Also, there are tests for etcupdate in usr.sbin/etcupdate/tests/

Updated diff addressing @bsdimp's comments. I changed the "$var"/"something" to "$var/something" to make it easier to read. When required, I can also wrap those variables to be ${var} if necessary.

bcr marked 4 inline comments as done.Jun 20 2023, 5:14 PM