Skip to content

Commit 8d07671

Browse files
fix: preserve prompt quoting in gemini CLI invocation
The GEMINI_ARGS variable caused word-splitting on the multi-line PROMPT string, breaking the gemini CLI argument parsing. Use a separate DEBUG_FLAG variable instead and keep "${PROMPT}" quoted in each invocation. Ref: #479
1 parent 8023d45 commit 8d07671

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

action.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,30 +311,30 @@ runs:
311311
# Keep track of whether we've failed
312312
FAILED=false
313313
314-
# Build the base command arguments
315-
GEMINI_ARGS="--yolo --prompt ${PROMPT} --output-format json"
314+
# Determine debug flag
315+
DEBUG_FLAG=""
316316
if [[ "${GEMINI_DEBUG}" = true ]]; then
317-
GEMINI_ARGS="--debug ${GEMINI_ARGS}"
317+
DEBUG_FLAG="--debug"
318318
fi
319319
320320
# Run Gemini CLI with the provided prompt, using JSON output format
321321
# We capture stdout (JSON) to TEMP_STDOUT and stderr to TEMP_STDERR
322322
if [[ "${OUTPUT_TO_FILE}" = true ]]; then
323323
echo "::notice::Gemini CLI output redirected to files (gemini-artifacts/)"
324-
if ! gemini ${GEMINI_ARGS} 2> "${TEMP_STDERR}" 1> "${TEMP_STDOUT}"; then
324+
if ! gemini ${DEBUG_FLAG} --yolo --prompt "${PROMPT}" --output-format json 2> "${TEMP_STDERR}" 1> "${TEMP_STDOUT}"; then
325325
FAILED=true
326326
fi
327327
elif [[ "${GEMINI_DEBUG}" = true ]]; then
328328
echo "::warning::Gemini CLI debug logging is enabled. This will stream responses, which could reveal sensitive information if processed with untrusted inputs."
329329
echo "::: Start Gemini CLI STDOUT :::"
330-
if ! gemini ${GEMINI_ARGS} 2> >(tee "${TEMP_STDERR}" >&2) | tee "${TEMP_STDOUT}"; then
330+
if ! gemini ${DEBUG_FLAG} --yolo --prompt "${PROMPT}" --output-format json 2> >(tee "${TEMP_STDERR}" >&2) | tee "${TEMP_STDOUT}"; then
331331
FAILED=true
332332
fi
333333
# Wait for async stderr logging to complete. This is because process substitution in Bash is async so let tee finish writing to ${TEMP_STDERR}
334334
sleep 1
335335
echo "::: End Gemini CLI STDOUT :::"
336336
else
337-
if ! gemini ${GEMINI_ARGS} 2> "${TEMP_STDERR}" 1> "${TEMP_STDOUT}"; then
337+
if ! gemini --yolo --prompt "${PROMPT}" --output-format json 2> "${TEMP_STDERR}" 1> "${TEMP_STDOUT}"; then
338338
FAILED=true
339339
fi
340340
fi

0 commit comments

Comments
 (0)