From 729d344788510b1a68852148eb627ec361751f6e Mon Sep 17 00:00:00 2001 From: RoomWithOutRoof Date: Sat, 7 Mar 2026 10:08:56 +0800 Subject: [PATCH] fix: strip shell comments before parsing claude_args 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 #802 --- base-action/src/parse-sdk-options.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/base-action/src/parse-sdk-options.ts b/base-action/src/parse-sdk-options.ts index 35df281d2..586be2e0c 100644 --- a/base-action/src/parse-sdk-options.ts +++ b/base-action/src/parse-sdk-options.ts @@ -24,6 +24,19 @@ const ACCUMULATING_FLAGS = new Set([ // Delimiter used to join accumulated flag values const ACCUMULATE_DELIMITER = "\x00"; +/** + * Strip shell-style comments from input before parsing. + * Shell-quote treats # as a comment character, swallowing all content after it. + * This function removes lines that start with # (after trimming) to prevent + * flags after comments from being swallowed. + */ +function stripShellComments(input: string): string { + return input + .split("\n") + .filter((line) => !line.trim().startsWith("#")) + .join("\n"); +} + type McpConfig = { mcpServers?: Record; }; @@ -91,8 +104,11 @@ function parseClaudeArgsToExtraArgs( ): Record { if (!claudeArgs?.trim()) return {}; + // Strip shell comments before parsing to prevent # from swallowing subsequent flags + const strippedArgs = stripShellComments(claudeArgs); + const result: Record = {}; - const args = parseShellArgs(claudeArgs).filter( + const args = parseShellArgs(strippedArgs).filter( (arg): arg is string => typeof arg === "string", );