mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-08-22 03:18:54 +08:00
fix: strip shell comment lines before parsing claude_args (#1055)
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 #802 Co-authored-by: VoidChecksum <Admin@CyberNord>
This commit is contained in:
co-authored by
VoidChecksum
parent
f328a5c889
commit
eb8baa46af
@@ -313,6 +313,42 @@ describe("parseSdkOptions", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("shell comment stripping", () => {
|
||||
test("should parse flags before and after a comment line", () => {
|
||||
const options: ClaudeOptions = {
|
||||
claudeArgs: "--model 'claude-haiku'\n# comment\n--allowed-tools 'Edit'",
|
||||
};
|
||||
|
||||
const result = parseSdkOptions(options);
|
||||
|
||||
expect(result.sdkOptions.extraArgs?.["model"]).toBe("claude-haiku");
|
||||
expect(result.sdkOptions.allowedTools).toEqual(["Edit"]);
|
||||
});
|
||||
|
||||
test("should parse flags correctly when no comments are present", () => {
|
||||
const options: ClaudeOptions = {
|
||||
claudeArgs: "--model 'claude-haiku'",
|
||||
};
|
||||
|
||||
const result = parseSdkOptions(options);
|
||||
|
||||
expect(result.sdkOptions.extraArgs?.["model"]).toBe("claude-haiku");
|
||||
});
|
||||
|
||||
test("should not strip inline # that appears inside a quoted value", () => {
|
||||
const options: ClaudeOptions = {
|
||||
claudeArgs: "--model 'claude-haiku' --prompt 'use color #ff0000'",
|
||||
};
|
||||
|
||||
const result = parseSdkOptions(options);
|
||||
|
||||
expect(result.sdkOptions.extraArgs?.["model"]).toBe("claude-haiku");
|
||||
expect(result.sdkOptions.extraArgs?.["prompt"]).toBe(
|
||||
"use color #ff0000",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("environment variables passthrough", () => {
|
||||
test("should include OTEL environment variables in sdkOptions.env", () => {
|
||||
// Set up test environment variables
|
||||
|
||||
Reference in New Issue
Block a user