Skip to content

Commit a7705fd

Browse files
authored
Merge pull request #920 from Homebrew/unknown-options-error-display
2 parents 10ba024 + d86c784 commit a7705fd

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

install.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,6 @@ then
3939
abort 'Bash must not run in POSIX mode. Please unset POSIXLY_CORRECT and try again.'
4040
fi
4141

42-
usage() {
43-
cat <<EOS
44-
Homebrew Installer
45-
Usage: [NONINTERACTIVE=1] [CI=1] install.sh [options]
46-
-h, --help Display this message.
47-
NONINTERACTIVE Install without prompting for user input
48-
CI Install in CI mode (e.g. do not prompt for user input)
49-
EOS
50-
exit "${1:-0}"
51-
}
52-
53-
while [[ $# -gt 0 ]]
54-
do
55-
case "$1" in
56-
-h | --help) usage ;;
57-
*)
58-
warn "Unrecognized option: '$1'"
59-
usage 1
60-
;;
61-
esac
62-
done
63-
6442
# string formatters
6543
if [[ -t 1 ]]
6644
then
@@ -98,6 +76,28 @@ warn() {
9876
printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")" >&2
9977
}
10078

79+
usage() {
80+
cat <<EOS
81+
Homebrew Installer
82+
Usage: [NONINTERACTIVE=1] [CI=1] install.sh [options]
83+
-h, --help Display this message.
84+
NONINTERACTIVE Install without prompting for user input
85+
CI Install in CI mode (e.g. do not prompt for user input)
86+
EOS
87+
exit "${1:-0}"
88+
}
89+
90+
while [[ $# -gt 0 ]]
91+
do
92+
case "$1" in
93+
-h | --help) usage ;;
94+
*)
95+
warn "Unrecognized option: '$1'"
96+
usage 1
97+
;;
98+
esac
99+
done
100+
101101
# Check if script is run non-interactively (e.g. CI)
102102
# If it is run non-interactively we should not prompt for passwords.
103103
# Always use single-quoted strings with `exp` expressions

0 commit comments

Comments
 (0)