Page MenuHomeFreeBSD

Run shellcheck through Mk/Scripts/
Needs ReviewPublic

Authored by mat on Jan 18 2018, 4:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 3:23 PM
Unknown Object (File)
Mar 19 2024, 9:59 AM
Unknown Object (File)
Mar 19 2024, 9:59 AM
Unknown Object (File)
Feb 3 2024, 6:22 PM
Unknown Object (File)
Jan 31 2024, 2:26 PM
Unknown Object (File)
Jan 30 2024, 4:54 PM
Unknown Object (File)
Jan 26 2024, 8:08 AM
Unknown Object (File)
Jan 9 2024, 12:48 AM
Subscribers
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary
  • SC2145: Argument mixes string and array. Use * or separate argument.
  • SC2068: Double quote array expansions to avoid re-splitting elements.
  • SC2221 & SC2222: This pattern always overrides a later/previous one.
  • SC2198: Arrays don't work as operands in [ ]. Use a loop (or concatenate with * instead of @).
  • SC2034: _results appears unused. Verify it or export it.
  • SC2163: Exporting an expansion rather than a variable.
  • SC2091: Remove surrounding $() to avoid executing output.
  • SC2153: Possible misspelling: PORTNAME may not be assigned, but portname is.
  • SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
  • SC2155: Declare and assign separately to avoid masking return values.
  • SC2006: Use $(..) instead of legacy ...
  • SC2046: Quote this to prevent word splitting.
  • SC2185: Some finds don't have a default path. Specify '.' explicitly.
  • Don't exec with a pipe afterwards, it is weird.
  • SC2015: Note that A && B || C is not if-then-else. C may run when A is true.
  • SC2162: read without -r will mangle backslashes.
  • SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
  • SC1004: This backslash+linefeed is literal. Break outside single quotes if you just want to break the line.
  • SC1117: Backslash is literal in "\X". Prefer explicit escaping: "\\X".
  • SC2196: egrep is non-standard and deprecated. Use grep -E instead.

Diff Detail

Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 21925
Build 21169: arc lint + arc unit

Event Timeline

  • SC2086: Double quote to prevent globbing and word splitting.

This whole patch is huge! Please commit it on a per-script basis.

  • SC1117: Backslash is literal in "\X". Prefer explicit escaping: "\\X".
  • rebase
  • SC2196: egrep is non-standard and deprecated. Use grep -E instead.
  • SC2166: Prefer [ p ] ||/&& [ q ] as [ p -o/-a q ] is not well defined.
  • SC2039: In POSIX sh, echo flags are undefined.
  • Rename both variables, the GROUPS variable conflicts with an internal
Mk/Scripts/actual-package-depends.sh
5

I presume this is "SC2166: Prefer [ p ] ||/&& [ q ] as [ p -o/-a q ] is not well defined"? Can you elaborate a bit on how exactly this is not well defined? Personally I find -o form easier to read and understand.

Mk/Scripts/check-stagedir.sh
233

Ditto.

Mk/Scripts/check-vulnerable.sh
12

Here as well...

Mk/Scripts/check_leftovers.sh
26

And here, and below.

Mk/Scripts/smart_makepatch.sh
54–56

Why / (slash) is quoted here? I don't see how it's needed.

About SC2166:

Both -a and -o are obsolescent extensions in POSIX:

The XSI extensions specifying the -a and -o binary primaries and the '(' and ')' operators have been marked obsolescent. (Many expressions using them are ambiguously defined by the grammar depending on the specific expressions being evaluated.) Scripts using these expressions should be converted to the forms given below. Even though many implementations will continue to support these obsolescent forms, scripts should be extremely careful when dealing with user-supplied input that could be confused with these and other primaries and operators.

Expand each commit to give the rationale behind it.

Fix regressions and rebase.

  • SC2231: Quote expansions in for loop glob to prevent wordsplitting.
  • SC2230: which is non-standard. Use builtin 'command -v' instead.

Rebase.

  • SC2064: Use single quotes, otherwise this expands now rather than when

Rebase, add SC2223, remove SC2086 (to be done last).