Skip to content

Commit 9031fc3

Browse files
ComBbaclaude
andcommitted
fix(cache): use python for mtime instead of stat (portable across macOS/Linux)
CI failure: scripts/preview-cache.sh used macOS-only stat -f %m. On Linux, stat -f means "filesystem info" (prints "File: ...") and doesn't fall through to the -c %Y branch, causing "File: unbound variable" under set -u. Replaced with python3 os.path.getmtime + time.time() — portable, no platform branching needed. stdlib-only so still complies with LESSON 0.4 (no deps). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fba3cde commit 9031fc3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

scripts/preview-cache.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ print(json.load(open('$PLUGIN_ROOT/profiles/$profile_name.json'))['caching']['tt
8787
fi
8888

8989
if [[ "$ttl" -gt 0 ]]; then
90-
local age=$(($(date +%s) - $(stat -f %m "$file" 2>/dev/null || stat -c %Y "$file")))
90+
local age
91+
age=$(python3 -c "import os,time; print(int(time.time() - os.path.getmtime('$file')))")
9192
if [[ "$age" -gt "$ttl" ]]; then
9293
return 1
9394
fi
@@ -139,7 +140,8 @@ print(json.load(open('$PLUGIN_ROOT/profiles/$profile_name.json'))['caching']['tt
139140
removed=$((removed + 1))
140141
continue
141142
fi
142-
local age=$(($(date +%s) - $(stat -f %m "$f" 2>/dev/null || stat -c %Y "$f")))
143+
local age
144+
age=$(python3 -c "import os,time; print(int(time.time() - os.path.getmtime('$f')))")
143145
if [[ "$age" -gt "$ttl" ]]; then
144146
rm -f "$f"
145147
removed=$((removed + 1))

0 commit comments

Comments
 (0)