fix: use eval for browser command to handle quoted arguments

Browser commands like `open -a 'Microsoft Edge'` need eval so
quotes inside the variable are interpreted as shell syntax,
not literal characters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vincent Yan 2026-02-14 17:17:17 -05:00
parent 7adaeb3128
commit 01813c1d9d
2 changed files with 10 additions and 1 deletions

View file

@ -301,4 +301,4 @@ if (( print_only )); then
fi
# open it in a browser
${BROWSER:-${browser:-$open}} "$openurl"
eval "${BROWSER:-${browser:-$open}}" \"\$openurl\"

View file

@ -701,6 +701,15 @@ setup() {
assert_output "DEFAULT https://github.com/personal/repo"
}
@test "browser: handles quoted arguments in browser command" {
git remote set-url origin "git@github.com:user/repo.git"
git checkout -B "master"
git config --local open.browser "echo 'spaced arg'"
unset BROWSER
run ../git-open
assert_output "spaced arg https://github.com/user/repo"
}
@test "browser: BROWSER env var takes priority over config" {
git remote set-url origin "git@github.com:user/repo.git"
git checkout -B "master"