@@ -114,29 +114,43 @@ then
114114 HOMEBREW_TEMP=" ${HOMEBREW_DEFAULT_TEMP} "
115115fi
116116
117- # commands that take a single or no arguments.
118- # HOMEBREW_LIBRARY set by bin/brew
119- # shellcheck disable=SC2154
120- # doesn't need a default case as other arguments handled elsewhere.
121- # shellcheck disable=SC2249
122- case " $1 " in
123- formulae)
124- source " ${HOMEBREW_LIBRARY} /Homebrew/cmd/formulae.sh"
125- homebrew-formulae
126- exit 0
127- ;;
128- casks)
129- source " ${HOMEBREW_LIBRARY} /Homebrew/cmd/casks.sh"
130- homebrew-casks
131- exit 0
132- ;;
133- shellenv)
134- source " ${HOMEBREW_LIBRARY} /Homebrew/cmd/shellenv.sh"
135- shift
136- homebrew-shellenv " $1 "
137- exit 0
138- ;;
139- esac
117+ for arg in " $@ "
118+ do
119+ [[ " ${arg} " == " --" ]] && break
120+
121+ if [[ " ${arg} " == " --help" || " ${arg} " == " -h" || " ${arg} " == " --usage" || " ${arg} " == " -?" ]]
122+ then
123+ export HOMEBREW_HELP=" 1"
124+ break
125+ fi
126+ done
127+
128+ if [[ -z " ${HOMEBREW_HELP} " ]]
129+ then
130+ # commands that take a single or no arguments.
131+ # HOMEBREW_LIBRARY set by bin/brew
132+ # shellcheck disable=SC2154
133+ # doesn't need a default case as other arguments handled elsewhere.
134+ # shellcheck disable=SC2249
135+ case " $1 " in
136+ formulae)
137+ source " ${HOMEBREW_LIBRARY} /Homebrew/cmd/formulae.sh"
138+ homebrew-formulae
139+ exit 0
140+ ;;
141+ casks)
142+ source " ${HOMEBREW_LIBRARY} /Homebrew/cmd/casks.sh"
143+ homebrew-casks
144+ exit 0
145+ ;;
146+ shellenv)
147+ source " ${HOMEBREW_LIBRARY} /Homebrew/cmd/shellenv.sh"
148+ shift
149+ homebrew-shellenv " $1 "
150+ exit 0
151+ ;;
152+ esac
153+ fi
140154
141155source " ${HOMEBREW_LIBRARY} /Homebrew/help.sh"
142156
@@ -192,19 +206,22 @@ esac
192206source " ${HOMEBREW_LIBRARY} /Homebrew/utils/wrapper.sh"
193207check-brew-wrapper " $1 "
194208
195- # commands that take a single or no arguments and need to write to HOMEBREW_PREFIX.
196- # HOMEBREW_LIBRARY set by bin/brew
197- # shellcheck disable=SC2154
198- # doesn't need a default case as other arguments handled elsewhere.
199- # shellcheck disable=SC2249
200- case " $1 " in
201- setup-ruby)
202- source " ${HOMEBREW_LIBRARY} /Homebrew/cmd/setup-ruby.sh"
203- shift
204- homebrew-setup-ruby " $1 "
205- exit 0
206- ;;
207- esac
209+ if [[ -z " ${HOMEBREW_HELP} " ]]
210+ then
211+ # commands that take a single or no arguments and need to write to HOMEBREW_PREFIX.
212+ # HOMEBREW_LIBRARY set by bin/brew
213+ # shellcheck disable=SC2154
214+ # doesn't need a default case as other arguments handled elsewhere.
215+ # shellcheck disable=SC2249
216+ case " $1 " in
217+ setup-ruby)
218+ source " ${HOMEBREW_LIBRARY} /Homebrew/cmd/setup-ruby.sh"
219+ shift
220+ homebrew-setup-ruby " $1 "
221+ exit 0
222+ ;;
223+ esac
224+ fi
208225
209226# ####
210227# #### Next, define all other helper functions.
559576# commands that take a single or no arguments.
560577# doesn't need a default case as other arguments handled elsewhere.
561578# shellcheck disable=SC2249
562- case " $1 " in
579+ case " $@ " in
563580 --version | -v)
564581 source " ${HOMEBREW_LIBRARY} /Homebrew/cmd/--version.sh"
565582 homebrew-version
852869 fi
853870fi
854871
855- for arg in " $@ "
856- do
857- [[ " ${arg} " == " --" ]] && break
858-
859- if [[ " ${arg} " == " --help" || " ${arg} " == " -h" || " ${arg} " == " --usage" || " ${arg} " == " -?" ]]
860- then
861- export HOMEBREW_HELP=" 1"
862- break
863- fi
864- done
865-
866872HOMEBREW_ARG_COUNT=" $# "
867873HOMEBREW_COMMAND=" $1 "
868874shift
@@ -1077,7 +1083,7 @@ unset SUDO
10771083# Remove internal variables
10781084unset HOMEBREW_INTERNAL_ALLOW_PACKAGES_FROM_PATHS
10791085
1080- if [[ -n " ${HOMEBREW_BASH_COMMAND} " ]]
1086+ if [[ -n " ${HOMEBREW_BASH_COMMAND} " ]] && [[ -z " ${HOMEBREW_HELP} " ]]
10811087then
10821088 # source rather than executing directly to ensure the entire file is read into
10831089 # memory before it is run. This makes running a Bash script behave more like
0 commit comments