knative / client

Knative developer experience, docs, reference Knative CLI implementation
Apache License 2.0
354 stars 261 forks source link

Fix shellcheck warnings in hack/build.sh script #1859

Closed dsimansk closed 1 year ago

dsimansk commented 1 year ago

There are a few warnings in our ./hack/build.sh script that would be nice to fix. It might pop-up in case of changing the script in the future.

There are several more with INFO severity level. Those can be ignored for now.

➜  client git:(main) shellcheck -S warning hack/build.sh

In hack/build.sh line 40:
  pushd $(basedir) >/dev/null 2>&1
        ^--------^ SC2046 (warning): Quote this to prevent word splitting.

In hack/build.sh line 43:
  if $(has_flag --help -h); then
     ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 48:
  if $(has_flag --watch -w); then
     ^--------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 52:
    if $(has_flag --test -t); then
       ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 61:
  if $(has_flag --fast -f); then
     ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 64:
    if $(has_flag --test -t); then
       ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 71:
  if $(has_flag --test -t); then
     ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 77:
  if $(has_flag --codegen -c); then
     ^----------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 83:
  if $(has_flag --all -x); then
     ^------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 118:
  find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
       ^--------------------^ SC2046 (warning): Quote this to prevent word splitting.

In hack/build.sh line 123:
  go_run "golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION}" -w $(echo "$source_dirs")
                                                                    ^--------------------^ SC2046 (warning): Quote this to prevent word splitting.

In hack/build.sh line 124:
  find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
       ^--------------------^ SC2046 (warning): Quote this to prevent word splitting.

In hack/build.sh line 139:
  if $(file kn | grep -q -i "Windows"); then
     ^-- SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 199:
  $(basedir)/hack/update-deps.sh
  ^--------^ SC2046 (warning): Quote this to prevent word splitting.

In hack/build.sh line 211:
    local fswatch_opts='-e "^\..*$" -o pkg cmd'
                       ^----------------------^ SC2089 (warning): Quotes/backslashes will be treated literally. Use an array.

In hack/build.sh line 212:
    if $(has_flag --test -t); then
       ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 215:
    if $(has_flag --verbose); then
       ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 231:
    fswatch $fswatch_opts | xargs -n1 -I{} sh -c "$command && echo 👌 OK"
            ^-----------^ SC2090 (warning): Quotes/backslashes in this variable will not be respected.

In hack/build.sh line 261:
    filters="$@"
            ^--^ SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.

In hack/build.sh line 321:
display_help() {
^-- SC2120 (warning): display_help references arguments, but none are ever passed.

In hack/build.sh line 326:
Usage: $(basename $BASH_SOURCE) [... options ...]
                  ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.

In hack/build.sh line 356:
if $(has_flag --debug); then
   ^-----------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).

In hack/build.sh line 362:
source $(basedir)/vendor/knative.dev/hack/library.sh
       ^--------^ SC2046 (warning): Quote this to prevent word splitting.

In hack/build.sh line 366:
  source "${file}"
         ^-------^ SC1090 (warning): ShellCheck can't follow non-constant source. Use a directive to specify location.

In hack/build.sh line 368:
source $(basedir)/hack/build-flags.sh
       ^--------^ SC2046 (warning): Quote this to prevent word splitting.

For more information:
  https://www.shellcheck.net/wiki/SC1090 -- ShellCheck can't follow non-const...
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2089 -- Quotes/backslashes will be treate...

/kind cleanup /kind good-first-issue

xiangpingjiang commented 1 year ago

/assign