cmd/update-reset: improve arg validation

This is based on feedback from #14667.
This commit is contained in:
Carlo Cabrera 2023-02-28 20:38:00 +08:00
parent 12364d70d2
commit 53053e0625
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -1,4 +1,4 @@
#: * `update-reset` [<repository> ...]
#: * `update-reset` [<path-to-tap-repository> ...]
#:
#: Fetch and reset Homebrew and all tap repositories (or any specified <repository>) using `git`(1) to their latest `origin/HEAD`.
#:
@ -33,7 +33,14 @@ homebrew-update-reset() {
[[ "${option}" == *d* ]] && HOMEBREW_DEBUG=1
;;
*)
REPOS+=("${option}")
if [[ -d "${option}/.git" ]]
then
REPOS+=("${option}")
else
onoe "${option} is not a Git repository!"
brew help update-reset
exit 1
fi
;;
esac
done