Skip to content

fix: strip shell comments before parsing claude_args#1027

Closed
Jah-yee wants to merge 1 commit intoanthropics:mainfrom
Jah-yee:fix/shell-comment-stripping
Closed

fix: strip shell comments before parsing claude_args#1027
Jah-yee wants to merge 1 commit intoanthropics:mainfrom
Jah-yee:fix/shell-comment-stripping

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Mar 7, 2026

Summary

Prevents # characters in claude_args from swallowing subsequent flags. The shell-quote library treats # as a shell comment character, which breaks configurations where users add explanatory comments.

Problem

When users include shell-style comments in their claude_args, all content after # is swallowed, including subsequent flags:

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

The --allowed-tools flag is never parsed because shell-quote treats everything after # as a comment.

Solution

Strip shell-style comment lines (lines starting with # after trimming) before parsing with shell-quote:

function stripShellComments(input: string): string {
  return input
    .split("\n")
    .filter((line) => !line.trim().startsWith("#"))
    .join("\n");
}

Fixes

Fixes #802

Prevents # characters in claude_args from swallowing subsequent flags.
Shell-quote treats # as a shell comment, which breaks configurations
where users add explanatory comments (e.g., --model followed by
# comment and --allowed-tools).

Fixes anthropics#802
@ashwin-ant
Copy link
Copy Markdown
Collaborator

Closing in favor of #1055

@ashwin-ant ashwin-ant closed this Apr 5, 2026
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

2 participants