From 45bc02952de486b18d230f08bcccea708c738f6a Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 15 Aug 2026 08:40:12 -0700 Subject: [PATCH] =?UTF-8?q?fix(bin):=20gstack-codex-session-import=20?= =?UTF-8?q?=E2=80=94=20empty=20sessions=20dir=20exits=200=20on=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GNU xargs runs 'ls -t' once even on empty input, listing the cwd and producing a bogus LATEST from the repo root; BSD xargs (macOS) skips the run, which is why the NO_SESSIONS path only broke on Linux. xargs -r pins the BSD behavior on both platforms. Co-Authored-By: Claude Fable 5 --- bin/gstack-codex-session-import | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/gstack-codex-session-import b/bin/gstack-codex-session-import index 91368cac9..7b1c5f07c 100755 --- a/bin/gstack-codex-session-import +++ b/bin/gstack-codex-session-import @@ -64,8 +64,11 @@ case "$MODE" in echo "NO_SESSIONS: $CODEX_SESSIONS_ROOT does not exist" exit 0 fi + # xargs -r: GNU xargs runs `ls -t` once even on EMPTY input (listing the + # cwd and producing a bogus LATEST); BSD xargs skips it. -r pins the + # BSD behavior on both. LATEST=$(find "$CODEX_SESSIONS_ROOT" -type f -name "rollout-*.jsonl" -print 2>/dev/null \ - | xargs ls -t 2>/dev/null | head -1 || true) + | xargs -r ls -t 2>/dev/null | head -1 || true) if [ -z "$LATEST" ]; then echo "NO_SESSIONS: no rollout-*.jsonl files under $CODEX_SESSIONS_ROOT" exit 0