diff --git a/git-open b/git-open index de056e9..b7b55cb 100755 --- a/git-open +++ b/git-open @@ -46,7 +46,8 @@ done # parse suffix from suffix=value IFS='=' read -ra suffix_flag <<< "$suffix_flag" -suffix=${suffix_flag[1]} +function join_by { local IFS="$1"; shift; echo "$*"; } +suffix=$(join_by "=" "${suffix_flag[@]:1}") # are we in a git repo? if ! git rev-parse --is-inside-work-tree &>/dev/null; then @@ -143,7 +144,7 @@ else # Resolve sshconfig aliases if [[ -e "$ssh_config" ]]; then domain_resolv=$(ssh_resolve "$domain") - if [[ ! -z "$domain_resolv" ]]; then + if [[ -n "$domain_resolv" ]]; then domain="$domain_resolv" fi fi diff --git a/test/git-open.bats b/test/git-open.bats index 854f274..73ef6bd 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -172,6 +172,11 @@ setup() { assert_output "https://github.com/paulirish/git-open/anySuffix" } +@test "gh: git open --suffix anySuffix?hello=world" { + run ../git-open "--suffix" "anySuffix?hello=world" + assert_output "https://github.com/paulirish/git-open/anySuffix?hello=world" +} + @test "gh: gist" { git remote set-url origin "git@gist.github.com:2d84a6db1b41b4020685.git" run ../git-open