Merge pull request #9130 from dokku/fix-ssh-arg-splitting

Preserve arguments such as --version and -n when running commands over SSH
This commit is contained in:
Jose Diaz-Gonzalez authored and GitHub committed 2026-10-14 15:13:13 -04:00
commit 94a82bd6ee
3 files changed
+29 -1

No files matched your search

+1 -1
View File
@@ -118,7 +118,7 @@ if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then
exit_code=$? exit_code=$?
set +f set +f
else else
readarray -t -O "${#ssh_arg_array[@]}" ssh_arg_array < <(printf '%s' "$SSH_ORIGINAL_COMMAND" | xargs -n 1) readarray -d '' -O "${#ssh_arg_array[@]}" ssh_arg_array < <(printf '%s' "$SSH_ORIGINAL_COMMAND" | xargs -r printf '%s\0')
set -f set -f
$0 "${ssh_arg_array[@]}" $0 "${ssh_arg_array[@]}"
exit_code=$? exit_code=$?
+8
View File
@@ -37,6 +37,14 @@ teardown() {
assert_success assert_success
} }
@test "(core) ssh arguments are passed through unchanged" {
run ssh "dokku@$DOKKU_DOMAIN" fakecommand --version --help -n -e -E
echo "output: $output"
echo "status: $status"
assert_failure
assert_output_contains '`fakecommand --version --help -n -e -E` is not a dokku command.'
}
@test "(core) urls (non-ssl)" { @test "(core) urls (non-ssl)" {
assert_urls "http://${TEST_APP}.${DOKKU_DOMAIN}" assert_urls "http://${TEST_APP}.${DOKKU_DOMAIN}"
+20
View File
@@ -30,6 +30,26 @@ teardown() {
assert_failure assert_failure
} }
@test "(run) run over ssh preserves echo-like arguments" {
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "ssh dokku@$DOKKU_DOMAIN run $TEST_APP /bin/echo --version --help 2>/dev/null"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "--version --help"
# bats strips trailing newlines from $output, so count bytes to verify -n was honored
run /bin/bash -c "ssh dokku@$DOKKU_DOMAIN run $TEST_APP /bin/echo -n hello 2>/dev/null | wc -c"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "5"
}
@test "(run) run:detached" { @test "(run) run:detached" {
run deploy_app run deploy_app
echo "output: $output" echo "output: $output"