Summary
Several scripts use stat -f %m <file> || stat -c %Y <file> to read mtime, putting the BSD form first. On Linux (GNU coreutils), stat -f means --file-system, not "format" — so the first command does not fail. It succeeds and prints filesystem-info text like File: "ops/config.yaml" to stdout. The || fallback never triggers, the non-numeric output flows into arithmetic, and the script errors.
Observed on session start:
SessionStart:startup hook error
Failed with non-blocking status code:
/root/.claude/plugins/cache/agenticnotetaking/arscontexta/0.8.0/hooks/scripts/session-orient.sh: line 146: File: "ops/config.yaml"
Affected files (v0.8.0)
hooks/scripts/session-orient.sh — lines ~142, ~145
skills/health/SKILL.md — line ~410
skill-sources/rethink/SKILL.md — lines ~89, ~91
Fix
Swap the order so the GNU/Linux form is tried first and BSD/macOS is the fallback:
# was:
stat -f %m "$f" 2>/dev/null || stat -c %Y "$f" 2>/dev/null
# fixed:
stat -c %Y "$f" 2>/dev/null || stat -f %m "$f" 2>/dev/null
This works on both platforms: GNU stat -c succeeds on Linux; on macOS it cleanly errors (unknown option) and falls through to BSD stat -f. The original order fails because GNU stat -f produces non-failing-but-wrong output rather than erroring.
Environment
- Linux 6.8.0 (Ubuntu)
- GNU coreutils
stat
- arscontexta plugin v0.8.0
- Claude Code
Happy to send a PR if useful.
Summary
Several scripts use
stat -f %m <file> || stat -c %Y <file>to read mtime, putting the BSD form first. On Linux (GNU coreutils),stat -fmeans--file-system, not "format" — so the first command does not fail. It succeeds and prints filesystem-info text likeFile: "ops/config.yaml"to stdout. The||fallback never triggers, the non-numeric output flows into arithmetic, and the script errors.Observed on session start:
Affected files (v0.8.0)
hooks/scripts/session-orient.sh— lines ~142, ~145skills/health/SKILL.md— line ~410skill-sources/rethink/SKILL.md— lines ~89, ~91Fix
Swap the order so the GNU/Linux form is tried first and BSD/macOS is the fallback:
This works on both platforms: GNU
stat -csucceeds on Linux; on macOS it cleanly errors (unknown option) and falls through to BSDstat -f. The original order fails because GNUstat -fproduces non-failing-but-wrong output rather than erroring.Environment
statHappy to send a PR if useful.