fix: use printf instead of echo in init container to prevent prompt corruption
Busybox echo interprets escape sequences by default (\c, \n, \t, \0NNN, etc.). If the prompt contains \c (common in file paths or shell references), echo silently stops output at that point, truncating the prompt file. This can leave Claude CLI with an empty or garbled stdin, causing it to hang with zero output — manifesting as endless keepalive messages in the UI. printf '%s' passes content through verbatim, avoiding the issue. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -181,7 +181,7 @@ describe("buildJobManifest", () => {
|
||||
it("write-prompt writes PROMPT_CONTENT to /tmp/prompt/prompt.txt", () => {
|
||||
const { job } = buildJobManifest({ ctx, selfPod });
|
||||
const init = job.spec?.template?.spec?.initContainers?.[0];
|
||||
expect(init?.command).toEqual(["sh", "-c", "echo \"$PROMPT_CONTENT\" > /tmp/prompt/prompt.txt"]);
|
||||
expect(init?.command).toEqual(["sh", "-c", "printf '%s' \"$PROMPT_CONTENT\" > /tmp/prompt/prompt.txt"]);
|
||||
});
|
||||
|
||||
it("write-prompt mounts prompt volume", () => {
|
||||
|
||||
@@ -359,7 +359,7 @@ export function buildJobManifest(input: JobBuildInput): JobBuildResult {
|
||||
name: "write-prompt",
|
||||
image: "busybox:1.36",
|
||||
imagePullPolicy: "IfNotPresent",
|
||||
command: ["sh", "-c", "echo \"$PROMPT_CONTENT\" > /tmp/prompt/prompt.txt"],
|
||||
command: ["sh", "-c", "printf '%s' \"$PROMPT_CONTENT\" > /tmp/prompt/prompt.txt"],
|
||||
env: [{ name: "PROMPT_CONTENT", value: prompt }],
|
||||
volumeMounts: [{ name: "prompt", mountPath: "/tmp/prompt" }],
|
||||
securityContext,
|
||||
|
||||
Reference in New Issue
Block a user