fix: strip shell comment lines before parsing claude_args#1055
Open
VoidChecksum wants to merge 1 commit intoanthropics:mainfrom
Open
fix: strip shell comment lines before parsing claude_args#1055VoidChecksum wants to merge 1 commit intoanthropics:mainfrom
VoidChecksum wants to merge 1 commit intoanthropics:mainfrom
Conversation
shell-quote treats # as a shell comment character, swallowing all subsequent content including flags on new lines. Strip comment lines (lines starting with #) before passing input to shell-quote. Fixes anthropics#802
There was a problem hiding this comment.
Pull request overview
This PR fixes a parsing bug where shell-quote interprets # as a comment delimiter and can swallow subsequent flags in multiline claudeArgs. The fix preprocesses the argument string by removing full comment lines before invoking shell-quote, and adds tests to cover the behavior.
Changes:
- Add
stripShellComments()to remove lines whose first non-whitespace character is#before parsing. - Apply comment stripping in
parseClaudeArgsToExtraArgs()prior to callingshell-quote. - Add unit tests to verify flags around comment lines still parse and inline
#in quoted values is preserved.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| base-action/src/parse-sdk-options.ts | Strips full-line # comments before shell-quote parsing to prevent later flags from being swallowed. |
| base-action/test/parse-sdk-options.test.ts | Adds regression tests for comment-line stripping and preserving inline # inside quoted values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shell-quotelibrary treats#as a shell comment character, causing all content after a#(including subsequent flags on new lines) to be silently swallowedclaude_argsYAML inadvertently break flag parsing#) before passing input toshell-quoteBefore
--allowed-toolsis silently dropped — shell-quote puts it inside a comment object.After
Comment lines are stripped before parsing, so both
--modeland--allowed-toolsare correctly parsed. Inline#within quoted values (e.g.,--prompt 'use color #ff0000') is preserved.Changes
base-action/src/parse-sdk-options.ts: AddstripShellComments()function, apply beforeparseShellArgs()base-action/test/parse-sdk-options.test.ts: Add 3 test cases covering comments, no comments, and inline#in valuesTest plan
#in quoted values is NOT strippedclaude_argsFixes #802