Files
tanweai__pua/hooks
xsser ccaa9c0227 fix(flavor-helper): initialize PUA_LANGUAGE to avoid unbound var under set -u
get_flavor() only assigned PUA_LANGUAGE inside the `if [ -f "$config" ]`
branch. Callers (frustration-trigger.sh / pua-loop-hook.sh /
failure-detector.sh) run under `set -euo pipefail`, so on first-run
users without ~/.pua/config.json, line 179's `[ "$PUA_LANGUAGE" = "zh" ]`
tripped `unbound variable` and exit 1 — throwing a red hook error on
every UserPromptSubmit.

Fix: declare `PUA_LANGUAGE=""` unconditionally at the top of get_flavor
so it always has a definition regardless of config file presence.

E2E verified: `set -euo pipefail; source flavor-helper.sh; get_flavor`
with no config → exits 0 instead of trapping.

Closes #144
Reported-by: @maj1999 (thorough repro + root-cause analysis)
2026-04-19 01:01:44 +08:00
..