Skip to content

Commit

Permalink
Merge pull request #920 from Homebrew/unknown-options-error-display
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocab authored Dec 26, 2024
2 parents 10ba024 + d86c784 commit a7705fd
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,6 @@ then
abort 'Bash must not run in POSIX mode. Please unset POSIXLY_CORRECT and try again.'
fi

usage() {
cat <<EOS
Homebrew Installer
Usage: [NONINTERACTIVE=1] [CI=1] install.sh [options]
-h, --help Display this message.
NONINTERACTIVE Install without prompting for user input
CI Install in CI mode (e.g. do not prompt for user input)
EOS
exit "${1:-0}"
}

while [[ $# -gt 0 ]]
do
case "$1" in
-h | --help) usage ;;
*)
warn "Unrecognized option: '$1'"
usage 1
;;
esac
done

# string formatters
if [[ -t 1 ]]
then
Expand Down Expand Up @@ -98,6 +76,28 @@ warn() {
printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")" >&2
}

usage() {
cat <<EOS
Homebrew Installer
Usage: [NONINTERACTIVE=1] [CI=1] install.sh [options]
-h, --help Display this message.
NONINTERACTIVE Install without prompting for user input
CI Install in CI mode (e.g. do not prompt for user input)
EOS
exit "${1:-0}"
}

while [[ $# -gt 0 ]]
do
case "$1" in
-h | --help) usage ;;
*)
warn "Unrecognized option: '$1'"
usage 1
;;
esac
done

# Check if script is run non-interactively (e.g. CI)
# If it is run non-interactively we should not prompt for passwords.
# Always use single-quoted strings with `exp` expressions
Expand Down

0 comments on commit a7705fd

Please sign in to comment.