Skip to content

fix: strip shell comment lines from claude_args before parsing#1019

Open
dpdanpittman wants to merge 1 commit intoanthropics:mainfrom
dpdanpittman:fix/strip-shell-comments-claude-args
Open

fix: strip shell comment lines from claude_args before parsing#1019
dpdanpittman wants to merge 1 commit intoanthropics:mainfrom
dpdanpittman:fix/strip-shell-comments-claude-args

Conversation

@dpdanpittman
Copy link

shell-quote treats # as a comment character, causing all content after a comment line to be swallowed. This strips lines starting with # before passing to parseShellArgs, so users can add documentation comments to their claude_args without breaking subsequent flags.

Fixes #802

Motivation and Context

As described in #802, users writing multi-line claude_args with explanatory comments like:

claude_args: |
  --model 'claude-haiku-4-5'
  # This is a comment
  --allowed-tools 'mcp__github_inline_comment__create_inline_comment'

find that --allowed-tools is never parsed because shell-quote treats everything after # as a comment object.

Changes

Added a stripShellComments() function that removes lines whose first non-whitespace character is # before passing the input to shell-quote's parse(). This is a line-level filter — hash characters inside quoted values on the same line as a flag are preserved.

File changed: base-action/src/parse-sdk-options.ts

How Has This Been Tested?

Added 4 new tests in base-action/test/parse-sdk-options.test.ts under a new shell comment stripping describe block:

  1. Comment line between flags — verifies flags after comments are parsed
  2. Indented comment lines — verifies leading whitespace before # is handled
  3. Multiple comment lines — verifies consecutive comments don't break parsing
  4. Hash inside quoted values — verifies Bash(echo #hello) is preserved

Full test suite passes: 656/656 tests pass.

Breaking Changes

None. This only strips comment lines before parsing. Users who don't use comments see no change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

shell-quote treats # as a comment character, causing all content after
a comment line to be swallowed. This strips lines starting with # before
passing to parseShellArgs, so users can add documentation comments to
their claude_args without breaking subsequent flags.

Fixes anthropics#802

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Jah-yee added a commit to Jah-yee/claude-code-action that referenced this pull request Mar 6, 2026
shell-quote treats # as a comment character, causing all content after
a comment line to be swallowed.

This fix strips lines starting with # before passing to parseShellArgs,
so users can add documentation comments to their claude_args without
breaking subsequent flags.

Fixes: anthropics#1019, anthropics#802
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.

shell-quote treats # as comment, swallowing all subsequent flags in claude_args

1 participant