From c2c93d1cc9e436db0e0ff18c39e017d7ba5abf57 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 30 Mar 2021 01:15:05 +0200 Subject: [PATCH] Run `shellcheck` on cask utils and shim scripts. --- Library/Homebrew/shims/linux/super/make | 5 +++-- Library/Homebrew/shims/mac/super/ruby | 3 +++ Library/Homebrew/shims/mac/super/xcrun | 11 ++++++----- Library/Homebrew/shims/scm/git | 2 ++ Library/Homebrew/shims/utils.sh | 6 ++++-- Library/Homebrew/style.rb | 11 +++++++---- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/shims/linux/super/make b/Library/Homebrew/shims/linux/super/make index 36412314a1..e8bd9f82ef 100755 --- a/Library/Homebrew/shims/linux/super/make +++ b/Library/Homebrew/shims/linux/super/make @@ -7,7 +7,7 @@ pathremove() { NEWPATH=${NEWPATH:+$NEWPATH:}$DIR fi done - export $PATHVARIABLE="$NEWPATH" + export "$PATHVARIABLE"="$NEWPATH" } if [[ -n "$HOMEBREW_MAKE" && "$HOMEBREW_MAKE" != "make" ]] @@ -16,7 +16,8 @@ then else SAVED_PATH="$PATH" pathremove "$HOMEBREW_LIBRARY/Homebrew/shims/linux/super" - export MAKE="$(which make)" + MAKE="$(which make)" + export MAKE export PATH="$SAVED_PATH" fi diff --git a/Library/Homebrew/shims/mac/super/ruby b/Library/Homebrew/shims/mac/super/ruby index 91921781ff..9a125dc7e2 100755 --- a/Library/Homebrew/shims/mac/super/ruby +++ b/Library/Homebrew/shims/mac/super/ruby @@ -1,6 +1,9 @@ #!/bin/bash + # System Ruby's mkmf on Mojave (10.14) and later require SDKROOT set to work correctly. +# Don't need shellcheck to follow the `source`. +# shellcheck disable=SC1090 source "$HOMEBREW_LIBRARY/Homebrew/shims/utils.sh" try_exec_non_system "$SHIM_FILE" "$@" diff --git a/Library/Homebrew/shims/mac/super/xcrun b/Library/Homebrew/shims/mac/super/xcrun index 9217ca4bbe..00c34f31b7 100755 --- a/Library/Homebrew/shims/mac/super/xcrun +++ b/Library/Homebrew/shims/mac/super/xcrun @@ -1,4 +1,5 @@ #!/bin/bash + # Historically, xcrun has had various bugs, and in some cases it didn't # work at all (e.g. CLT-only in the Xcode 4.3 era). This script emulates # it and attempts to avoid these issues. @@ -27,10 +28,10 @@ arg0=$1 shift exe="/usr/bin/${arg0}" -if [ -x "$exe" ]; then - if [ -n "$HOMEBREW_PREFER_CLT_PROXIES" ]; then +if [[ -x "$exe" ]]; then + if [[ -n "$HOMEBREW_PREFER_CLT_PROXIES" ]]; then exec "$exe" "$@" - elif [ -z "$HOMEBREW_SDKROOT" -o ! -d "$HOMEBREW_SDKROOT" ]; then + elif [[ -z "$HOMEBREW_SDKROOT" || ! -d "$HOMEBREW_SDKROOT" ]]; then exec "$exe" "$@" fi fi @@ -38,7 +39,7 @@ fi SUPERBIN=$(cd "${0%/*}" && pwd -P) exe=$(/usr/bin/xcrun --find "$arg0" 2>/dev/null) -if [ -x "$exe" -a "${exe%/*}" != "$SUPERBIN" ]; then +if [[ -x "$exe" && "${exe%/*}" != "$SUPERBIN" ]]; then exec "$exe" "$@" fi @@ -57,7 +58,7 @@ done IFS=$old_IFS echo >&2 " -Failed to execute $arg0 $@ +Failed to execute ${arg0} ${*} Xcode and/or the CLT appear to be misconfigured. Try one or both of the following: xcodebuild -license diff --git a/Library/Homebrew/shims/scm/git b/Library/Homebrew/shims/scm/git index 788b1cbb07..6b0382ad6e 100755 --- a/Library/Homebrew/shims/scm/git +++ b/Library/Homebrew/shims/scm/git @@ -9,6 +9,8 @@ then exit 1 fi +# Don't need shellcheck to follow the `source`. +# shellcheck disable=SC1090 source "$HOMEBREW_LIBRARY/Homebrew/shims/utils.sh" case "$(lowercase "$SHIM_FILE")" in diff --git a/Library/Homebrew/shims/utils.sh b/Library/Homebrew/shims/utils.sh index 7d90d7b697..9252bf7653 100644 --- a/Library/Homebrew/shims/utils.sh +++ b/Library/Homebrew/shims/utils.sh @@ -60,8 +60,10 @@ safe_exec() { fi if [[ "$HOMEBREW" = "print-path" ]] then - local dir="$(quiet_safe_cd "${arg0%/*}/" && pwd)" - local path="$(dirbasepath "$dir" "$arg0")" + local dir + dir="$(quiet_safe_cd "${arg0%/*}/" && pwd)" + local path + path="$(dirbasepath "$dir" "$arg0")" echo "$path" exit fi diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index 7511754fdb..8346871cc0 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -177,13 +177,16 @@ module Homebrew files = [ HOMEBREW_BREW_FILE, # TODO: HOMEBREW_REPOSITORY/"completions/bash/brew", - *Pathname.glob("#{HOMEBREW_LIBRARY}/Homebrew/*.sh"), - *Pathname.glob("#{HOMEBREW_LIBRARY}/Homebrew/cmd/*.sh"), - *Pathname.glob("#{HOMEBREW_LIBRARY}/Homebrew/utils/*.sh"), + *HOMEBREW_LIBRARY.glob("Homebrew/*.sh"), + *HOMEBREW_LIBRARY.glob("Homebrew/shims/**/*").map(&:realpath).uniq + .reject { |path| path.directory? || path.basename.to_s == "cc" }, + *HOMEBREW_LIBRARY.glob("Homebrew/{dev-,}cmd/*.sh"), + *HOMEBREW_LIBRARY.glob("Homebrew/{cask/,}utils/*.sh"), ] end - args = ["--shell=bash", "--", *files] # TODO: Add `--enable=all` to check for more problems. + # TODO: Add `--enable=all` to check for more problems. + args = ["--shell=bash", "--external-sources", "--", *files] case output_type when :print