aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2016-01-21 18:53:42 +0800
committerXu Cheng2016-01-21 21:14:55 +0800
commite3687a5ba21385025eb97522654f56557535ba75 (patch)
tree3214b55f3883b16edc447a418e1cc1303eb145c5 /Library
parente9096b070190f7637d14458797dff4fd03aa21e7 (diff)
downloadbrew-e3687a5ba21385025eb97522654f56557535ba75.tar.bz2
update-bash: use array for QUIET_ARGS
Per @UniqMartin's advice, avoid disabling shellcheck rules. Closes Homebrew/homebrew#48286. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Homebrew/cmd/update-bash.sh30
1 files changed, 13 insertions, 17 deletions
diff --git a/Library/Homebrew/cmd/update-bash.sh b/Library/Homebrew/cmd/update-bash.sh
index 38057896f..c135d6a29 100755
--- a/Library/Homebrew/cmd/update-bash.sh
+++ b/Library/Homebrew/cmd/update-bash.sh
@@ -103,11 +103,9 @@ read_current_revision() {
git rev-parse -q --verify HEAD
}
-# Don't warn about QUIET_ARGS; they need to be unquoted.
-# shellcheck disable=SC2086
pop_stash() {
[[ -z "$STASHED" ]] && return
- git stash pop $QUIET_ARGS
+ git stash pop "${QUIET_ARGS[@]}"
if [[ -n "$HOMEBREW_VERBOSE" ]]
then
echo "Restoring your stashed changes to $DIR:"
@@ -123,8 +121,6 @@ pop_stash_message() {
unset STASHED
}
-# Don't warn about QUIET_ARGS; they need to be unquoted.
-# shellcheck disable=SC2086
reset_on_interrupt() {
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
then
@@ -133,7 +129,7 @@ reset_on_interrupt() {
if [[ -n "$INITIAL_REVISION" ]]
then
- git reset --hard "$INITIAL_REVISION" $QUIET_ARGS
+ git reset --hard "$INITIAL_REVISION" "${QUIET_ARGS[@]}"
fi
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
@@ -146,8 +142,6 @@ reset_on_interrupt() {
exit 130
}
-# Don't warn about QUIET_ARGS; they need to be unquoted.
-# shellcheck disable=SC2086
pull() {
local DIR
local TAP_VAR
@@ -190,8 +184,8 @@ pull() {
fi
git -c "user.email=brew-update@localhost" \
-c "user.name=brew update" \
- stash save --include-untracked $QUIET_ARGS
- git reset --hard $QUIET_ARGS
+ stash save --include-untracked "${QUIET_ARGS[@]}"
+ git reset --hard "${QUIET_ARGS[@]}"
STASHED="1"
fi
@@ -201,9 +195,9 @@ pull() {
# it to `origin/#{@upstream_branch}`. Otherwise, just check it out.
if git merge-base --is-ancestor "$UPSTREAM_BRANCH" "origin/$UPSTREAM_BRANCH" &>/dev/null
then
- git checkout --force "$UPSTREAM_BRANCH" $QUIET_ARGS
+ git checkout --force "$UPSTREAM_BRANCH" "${QUIET_ARGS[@]}"
else
- git checkout --force -B "$UPSTREAM_BRANCH" "origin/$UPSTREAM_BRANCH" $QUIET_ARGS
+ git checkout --force -B "$UPSTREAM_BRANCH" "origin/$UPSTREAM_BRANCH" "${QUIET_ARGS[@]}"
fi
fi
@@ -215,9 +209,9 @@ pull() {
if [[ -n "$HOMEBREW_REBASE" ]]
then
- git rebase $QUIET_ARGS "origin/$UPSTREAM_BRANCH"
+ git rebase "${QUIET_ARGS[@]}" "origin/$UPSTREAM_BRANCH"
else
- git merge --no-edit --ff $QUIET_ARGS "origin/$UPSTREAM_BRANCH"
+ git merge --no-edit --ff "${QUIET_ARGS[@]}" "origin/$UPSTREAM_BRANCH"
fi
export HOMEBREW_UPDATE_AFTER"$TAP_VAR"="$(read_current_revision)"
@@ -226,7 +220,7 @@ pull() {
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
then
- git checkout "$INITIAL_BRANCH" $QUIET_ARGS
+ git checkout "$INITIAL_BRANCH" "${QUIET_ARGS[@]}"
pop_stash
else
pop_stash_message
@@ -295,7 +289,9 @@ EOS
if [[ -z "$HOMEBREW_VERBOSE" ]]
then
- QUIET_ARGS="-q"
+ QUIET_ARGS=(-q)
+ else
+ QUIET_ARGS=()
fi
# ensure GIT_CONFIG is unset as we need to operate on .git/config
@@ -316,7 +312,7 @@ EOS
cd "$DIR" || continue
UPSTREAM_BRANCH="$(upstream_branch)"
# the refspec ensures that the default upstream branch gets updated
- git fetch $QUIET_ARGS origin \
+ git fetch "${QUIET_ARGS[@]}" origin \
"refs/heads/$UPSTREAM_BRANCH:refs/remotes/origin/$UPSTREAM_BRANCH" &
done