Skip to content

NDC background subshell killed by inherited set -e #14

@vadimmarmer

Description

@vadimmarmer

Bug

The NDC (Now-Day Compression) step in save-session.sh consistently fails because the background subshell at lines 235–260 inherits set -e from the parent script. When claude -p returns, the NDC_JSON=$(...) assignment triggers set -e before the if [ $? -ne 0 ] error handler on line 242 can execute.

Result: now.md accumulates entries indefinitely and today-YYYY-MM-DD.md is never created by the automatic pipeline.

Reproduction

The ERR trap logs FAILED at line 272 (exit 1) on every NDC attempt. The NDC components (build-ndc-prompt, Haiku call, parse-haiku) all work correctly when run outside the subshell.

Log pattern:

[ndc] now.md → today-2026-04-07.md
[error] FAILED at line 272 (exit 1)

Fix

Add set +e at the top of the background subshell (line 235):

-        (NDC_ERR=$(mktemp "${TMPDIR:-/tmp}"/remember-ndc-err-XXXXXX.txt)
+        (set +e
+            NDC_ERR=$(mktemp "${TMPDIR:-/tmp}"/remember-ndc-err-XXXXXX.txt)

The existing if [ $? -ne 0 ] block already handles errors correctly — it just never gets reached with set -e active.

Tested on macOS, v0.4.0 marketplace install.


This bug was detected, debugged, and reported by Claude Code (Claude Opus 4.6).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions