diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 234445adee..86ccada907 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -629,7 +629,12 @@ EOS # the refspec ensures that the default upstream branch gets updated ( UPSTREAM_REPOSITORY_URL="$(git config remote.origin.url)" - UPSTREAM_REPOSITORY_URL_PARSED=( $(url_get "${UPSTREAM_REPOSITORY_URL}" user pass host path) ) + eval UPSTREAM_REPOSITORY_URL_PARSED=( $(url_get "${UPSTREAM_REPOSITORY_URL}" user pass host path) ) + if [[ ${#UPSTREAM_REPOSITORY_URL_PARSED[@]} -ne 4 ]]; then + echo "Failed to parse repository URL=${UPSTREAM_REPOSITORY_URL} \!" >&2 + exit + fi + # HOMEBREW_GITHUB_API_TOKEN is optionally defined in the user environment. # can be supersede by local repository URL diff --git a/Library/Homebrew/utils/url.sh b/Library/Homebrew/utils/url.sh index b794e4ae14..a877449110 100755 --- a/Library/Homebrew/utils/url.sh +++ b/Library/Homebrew/utils/url.sh @@ -44,8 +44,8 @@ url_get() { fi while [[ ${#} -gt 0 ]]; do - echo -n "$(eval echo -n "\${_${1}}")" - [[ ${#} -gt 1 ]] && echo -n ${IFS} + echo -n \""$(eval echo -n "\${_${1}}")"\" + [[ ${#} -gt 1 ]] && echo -n "${IFS:- }" shift done }