Skip to content

Quote exec command arguments - #1904

Open
cookesan wants to merge 1 commit into
basecamp:mainfrom
cookesan:quote-exec-arguments
Open

Quote exec command arguments#1904
cookesan wants to merge 1 commit into
basecamp:mainfrom
cookesan:quote-exec-arguments

Conversation

@cookesan

Copy link
Copy Markdown
Contributor

Summary

  • quote multiple exec arguments when Kamal collapses them into a remote shell command
  • keep the existing single-string command path unchanged
  • add regression coverage for an argument containing spaces

Fixes #1651

Testing

  • bin/test test/utils_test.rb test/cli/app_test.rb
  • bin/test test/utils_test.rb test/cli/app_test.rb test/cli/accessory_test.rb test/cli/server_test.rb
  • bin/test test/commands/app_test.rb test/commands/accessory_test.rb test/utils_test.rb
  • bundle exec rubocop --parallel
  • bin/test (local full-suite run: 857 runs, 3098 assertions, 3 failures, 3 errors; the isolated failures in test/commands/builder_test.rb:271 and test/commands/hook_test.rb:36 reproduce on clean upstream/main in this environment)

Copilot AI review requested due to automatic review settings June 28, 2026 22:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes argument quoting for kamal * exec when multiple CLI arguments are collapsed into a single remote shell command string, while preserving the existing behavior for single-string commands (e.g., "ruby -v").

Changes:

  • Update Kamal::Utils.join_commands to return the original string for single-argument commands and to shell-escape/join multi-argument commands via Shellwords.join.
  • Add unit coverage for join_commands to ensure single-string commands remain unchanged and multi-arg commands preserve spaced arguments.
  • Add a CLI regression test ensuring kamal app exec keeps a spaced argument intact in the emitted docker command.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
lib/kamal/utils.rb Implements Shellwords-based joining for multi-argument exec commands while preserving the single-string path.
test/utils_test.rb Adds focused unit tests for join_commands behavior (single string vs. multiple args).
test/cli/app_test.rb Adds a regression test asserting spaced exec arguments remain intact in output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kamal app exec does not quote it's arguments

2 participants