update.sh: reject unknown long opts

I accidentally typed `brew update --greedy` instead of `brew upgrade --greedy` and got some strange output.

This fix causes unrecognized long options to throw a usage message and exit like all the other subcommands.

Before:
```
% brew update --greedy
==> Updating Homebrew...
Usage: brew update-report [--auto-update] [--force]

The Ruby implementation of brew update. Never called manually.
[...]
```

After:
```
% brew update --greedy
Error: Unrecognized option '--greedy'
Usage: brew update, up [options]

Fetch the newest version of Homebrew and all formulae from GitHub using git(1)
and perform any necessary migrations.
[...]
```
This commit is contained in:
Adrian Ho 2025-01-12 23:08:31 +08:00
parent 2432d01884
commit 85c9551cd3

View File

@ -352,7 +352,11 @@ homebrew-update() {
HOMEBREW_SIMULATE_FROM_CURRENT_BRANCH=1
;;
--auto-update) export HOMEBREW_UPDATE_AUTO=1 ;;
--*) ;;
--*)
onoe "Unknown option: ${option}"
brew help update
exit 1
;;
-*)
[[ "${option}" == *v* ]] && HOMEBREW_VERBOSE=1
[[ "${option}" == *q* ]] && HOMEBREW_QUIET=1