Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Planning hooks crash on git-bash/Windows & Linux — stat -f is BSD-only

オープン
#2 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
shell

調査の方向性

Start with .claude/hooks/user-prompt-submit.sh, .claude/hooks/session-start.sh, and .claude/hooks/stop.sh, then reproduce with the command in the issue on a GNU system. Update the mtime handling and inspect tests/hooks/test-stop.sh for the deterministic timestamp case. Done means ./scripts/quality.sh passes all 56 tests on git-bash/Linux while macOS behavior remains working.

索引モデルが issue の本文から書いたものです。

説明

Environment

  • OS: Windows 11 (git-bash) — also affects any GNU coreutils system (Linux). Works fine on macOS, which is why it likely went unnoticed.
  • Affected files: .claude/hooks/user-prompt-submit.sh, .claude/hooks/session-start.sh, .claude/hooks/stop.sh

Summary

The planning hooks silently crash on git-bash / Linux. As a side effect, scripts/quality.sh fails (~17 hook test cases) and the UserPromptSubmit / Stop / SessionStart hooks never run — so the "surface the active plan" feature is effectively dead on Windows/Linux.

Note: the test suite reports 56/56 on macOS but the hooks never execute on GNU systems (Linux/git-bash) — which is why this likely went unnoticed.

Root cause

Each hook reads the file mtime with:

mtime=$(stat -f %m "$progress" 2>/dev/null || stat -c %Y "$progress" 2>/dev/null || echo 0)

stat -f %m is the BSD/macOS syntax (works on macOS). On GNU stat, -f means "display filesystem status" — it does not fail, it prints a non-numeric string. Since it's tried first, the || fallback to stat -c %Y never fires, $mtime gets text, and the next line if (( mtime > newest )) evaluates that text as a variable name. Under set -euo pipefail this throws:

.claude/hooks/user-prompt-submit.sh: line 28: File: unbound variable

and the hook exits 1.

Steps to reproduce (git-bash)

echo '{}' | bash .claude/hooks/user-prompt-submit.sh; echo $?   # prints 1, should be 0
./scripts/quality.sh                                            # fails on hook tests

Fix (cross-platform, no macOS regression)

Try GNU first, fall back to BSD, and guard that the result is numeric:

mtime=$(stat -c %Y "$progress" 2>/dev/null || stat -f %m "$progress" 2>/dev/null || echo 0)
[[ "$mtime" =~ ^[0-9]+$ ]] || mtime=0

Apply to all three hooks. On macOS, stat -c fails → falls back to stat -f %m (behavior unchanged); on GNU, stat -c %Y returns the epoch.

Bonus (minor, test robustness)

In tests/hooks/test-stop.sh, the "multi-feature" case uses a plain touch, which can tie on coarse-granularity filesystems (Windows) and make the strict > comparison pick the wrong file. Forcing an explicit time makes it deterministic:

touch -d '2037-01-01 00:00' .claude/plans/features/002-newer/progress.md

Result

After both changes, ./scripts/quality.sh passes 56/56 on git-bash.

主要言語
Shell
スター
18
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

似ている issue

Shell/Bash の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。