Merge pull request #449 from schoeffm/bugfix/fix-code-args-handling

Preserve spaces in quoted args
This commit is contained in:
musi
2025-08-06 20:53:36 +08:00
committed by GitHub

View File

@@ -39,13 +39,17 @@ export async function executeCodeCommand(args: string[] = []) {
// Execute claude command
const claudePath = process.env.CLAUDE_PATH || "claude";
// Properly join arguments to preserve spaces in quotes
// Wrap each argument in double quotes to preserve single and double quotes inside arguments
const joinedArgs = args.length > 0 ? args.map(arg => `"${arg.replace(/\"/g, '\\"')}"`).join(" ") : "";
// 🔥 CONFIG-DRIVEN: stdio configuration based on environment
const stdioConfig: StdioOptions = config.NON_INTERACTIVE_MODE
? ["pipe", "inherit", "inherit"] // Pipe stdin for non-interactive
: "inherit"; // Default inherited behavior
const claudeProcess = spawn(claudePath, args, {
const claudeProcess = spawn(claudePath + (joinedArgs ? ` ${joinedArgs}` : ""), [], {
env,
stdio: stdioConfig,
shell: true,