From c8d5808888b7f6c0c003645a05d384cb426b17fb Mon Sep 17 00:00:00 2001 From: Robert Koller Date: Mon, 16 Mar 2026 05:10:29 +0000 Subject: [PATCH] fix: add macOS guard for Codex and fix script/sh quoting - Codex delegation via delegate.sh now errors on macOS where BSD script does not support -c (points user to tmux-session.sh instead) - Wrap script -c command through bash -c so printf '%q' output is interpreted by bash, not /bin/sh (which may be dash) --- .../scripts/delegate.sh | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/skills/claude-codex-delegation/scripts/delegate.sh b/skills/claude-codex-delegation/scripts/delegate.sh index f73d3a38a6a..6403de9ae4e 100755 --- a/skills/claude-codex-delegation/scripts/delegate.sh +++ b/skills/claude-codex-delegation/scripts/delegate.sh @@ -98,9 +98,17 @@ if ! command -v timeout &> /dev/null; then exit 1 fi -if [[ "$AGENT" == "codex" ]] && ! command -v script &> /dev/null; then - echo "Error: 'script' (from util-linux) is required for Codex PTY support" >&2 - exit 1 +if [[ "$AGENT" == "codex" ]]; then + if ! command -v script &> /dev/null; then + echo "Error: 'script' (from util-linux) is required for Codex PTY support" >&2 + exit 1 + fi + # BSD script (macOS) does not support -c flag + if [[ "$(uname)" == "Darwin" ]]; then + echo "Error: Codex delegation via delegate.sh requires Linux (GNU script)." >&2 + echo "On macOS, use tmux-session.sh or run Codex directly with a PTY." >&2 + exit 1 + fi fi if [[ ! -d "$WORKDIR" ]]; then @@ -158,8 +166,10 @@ run_delegation() { $(build_claude_cmd) "$PROMPT" > "$LOG_FILE" 2>&1 || exit_code=$? ;; codex) - # Codex requires a PTY — use script(1) to provide one - script -q -c "$(build_codex_cmd) $(printf '%q' "$PROMPT")" "$LOG_FILE" || exit_code=$? + # Codex requires a PTY — use script(1) to provide one. + # Run through bash -c so printf '%q' quoting is interpreted correctly + # (script passes commands to /bin/sh which may be dash, not bash). + script -q -c "bash -c $(printf '%q' "$(build_codex_cmd) $(printf '%q' "$PROMPT")")" "$LOG_FILE" || exit_code=$? ;; esac