fix: session-orient hook crashes on Linux due to stat -f flag ambiguity#16
Open
ajmeese7 wants to merge 1 commit intoagenticnotetaking:mainfrom
Open
fix: session-orient hook crashes on Linux due to stat -f flag ambiguity#16ajmeese7 wants to merge 1 commit intoagenticnotetaking:mainfrom
ajmeese7 wants to merge 1 commit intoagenticnotetaking:mainfrom
Conversation
On Linux, `stat -f %m` does not fail -- `-f` invokes filesystem stats (statfs) which succeeds with multi-line output instead of a file mtime. This means the `|| stat -c %Y` fallback never triggers, and the garbage output gets fed into an arithmetic expression on line 146, crashing the hook with a syntax error. The fix detects the platform once by testing which stat syntax actually returns a valid mtime, trying Linux (`-c %Y`) first since `-f` is the ambiguous flag. Also fixes the same macOS-first stat pattern in skills/health/SKILL.md and skill-sources/rethink/SKILL.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The session-orient SessionStart hook crashes on Linux with an arithmetic syntax error at line 146. This causes a "SessionStart hook error" on every session start and resume.
The root cause is
stat -f %m-- intended as macOS syntax to get file modification time. On Linux,-fis a valid flag meaning "filesystem stats" (statfs), so instead of failing and falling through to the|| stat -c %Yfallback, it succeeds and dumps multi-line filesystem info to stdout. That garbage then gets fed into a bash arithmetic expression, producing:Fix
statsyntax returns a valid mtime, trying Linux (-c %Y) first since-fis the ambiguous flag. Wraps the detection in a helper function to avoid repeating the logic.Testing
Tested on Ubuntu (Linux 6.17.0) where the hook was consistently failing.
Verified the hook completes successfully with exit code 0 after the fix.