From 01813c1d9d613745c3ef36589072ec8640520b36 Mon Sep 17 00:00:00 2001 From: Vincent Yan Date: Sat, 14 Feb 2026 17:17:17 -0500 Subject: [PATCH] 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 --- git-open | 2 +- test/git-open.bats | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/git-open b/git-open index a0a11fd..ba6328f 100755 --- a/git-open +++ b/git-open @@ -301,4 +301,4 @@ if (( print_only )); then fi # open it in a browser -${BROWSER:-${browser:-$open}} "$openurl" +eval "${BROWSER:-${browser:-$open}}" \"\$openurl\" diff --git a/test/git-open.bats b/test/git-open.bats index 03818b3..f5e74f4 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -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"