Browse Source
Stock tclsh treats any leading-dash arg other than -encoding as argv for an interactive/stdin session: on a console it hangs at a prompt, with piped stdin it exits 0 silently ignoring the supposed one-liner. Agents habitually reach for -e (perl/python/node reflex), wasting time waiting on hung processes. - root AGENTS.md User Preferences: document the misparse, the correct patterns (temp .tcl file or script via stdin) and the defensive stdin-redirect habit - .claude/settings.json: PreToolUse hook denying Bash/PowerShell invocations of tclsh with -e, anchored to command position (start/pipe/semicolon/paren) so prose mentions in commit messages or grep args do not false-positive; corrective guidance returned to the agent - .gitignore: narrow the .claude ignore so shared settings.json is tracked while session-local files stay ignored - .fossil-settings: ignore-glob hand-derived per the no-negation rule (.claude/* wholesale + explicit fossil add of settings.json), exception set in AGENTS.md updated; fossil extras under-ignore check verified empty Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.commaster
5 changed files with 57 additions and 3 deletions
@ -0,0 +1,50 @@ |
|||||||
|
{ |
||||||
|
"permissions": { |
||||||
|
"allow": [ |
||||||
|
"Bash(tclsh90 src/tests/runtests.tcl *)", |
||||||
|
"Bash(tclsh src/tests/runtests.tcl *)", |
||||||
|
"Bash(/c/Users/sleek/AppData/Local/Apps/Tcl903/bin/tclsh90 src/tests/runtests.tcl *)", |
||||||
|
"Bash(\"C:/Users/sleek/AppData/Local/Apps/Tcl903/bin/tclsh.exe\" src/tests/runtests.tcl *)", |
||||||
|
"Bash(./bin/punk91.exe src/tests/runtests.tcl *)", |
||||||
|
"Bash(tclsh src/make.tcl *)", |
||||||
|
"Bash(tclsh90 src/make.tcl *)", |
||||||
|
"Bash(tclsh87 src/make.tcl *)", |
||||||
|
"Bash(/c/Users/sleek/AppData/Local/Apps/Tcl903/bin/tclsh90 src/make.tcl *)", |
||||||
|
"Bash(\"C:/Users/sleek/AppData/Local/Apps/Tcl903/bin/tclsh.exe\" src/make.tcl *)", |
||||||
|
"Bash(./bin/punk91.exe src/make.tcl *)", |
||||||
|
"Bash(./bin/punk902z.exe src/make.tcl *)", |
||||||
|
"Bash(./bin/punksys.exe src/make.tcl *)", |
||||||
|
"Bash(tclsh scriptlib/developer/goals_lint.tcl *)", |
||||||
|
"Bash(tclsh90 scriptlib/developer/goals_lint.tcl *)", |
||||||
|
"Bash(/c/Users/sleek/AppData/Local/Apps/Tcl903/bin/tclsh90 scriptlib/developer/goals_lint.tcl *)", |
||||||
|
"Bash(\"C:/Users/sleek/AppData/Local/Apps/Tcl903/bin/tclsh.exe\" scriptlib/developer/goals_lint.tcl *)", |
||||||
|
"PowerShell(tclsh scriptlib/developer/goals_lint.tcl *)", |
||||||
|
"PowerShell(tclsh90 scriptlib/developer/goals_lint.tcl *)", |
||||||
|
"PowerShell(& \"C:\\Users\\sleek\\AppData\\Local\\Apps\\Tcl903\\bin\\tclsh90.exe\" scriptlib/developer/goals_lint.tcl *)", |
||||||
|
"PowerShell(tclsh src/make.tcl *)", |
||||||
|
"PowerShell(tclsh90 src/make.tcl *)", |
||||||
|
"PowerShell(& \"C:\\Users\\sleek\\AppData\\Local\\Apps\\Tcl903\\bin\\tclsh90.exe\" src/make.tcl *)", |
||||||
|
"PowerShell(& c:\\repo\\jn\\shellspy\\bin\\punk902z.exe src/make.tcl *)", |
||||||
|
"PowerShell(Get-Process *)", |
||||||
|
"PowerShell(git status *)", |
||||||
|
"PowerShell(git log *)", |
||||||
|
"PowerShell(git diff *)" |
||||||
|
] |
||||||
|
}, |
||||||
|
"hooks": { |
||||||
|
"PreToolUse": [ |
||||||
|
{ |
||||||
|
"matcher": "Bash|PowerShell", |
||||||
|
"hooks": [ |
||||||
|
{ |
||||||
|
"type": "command", |
||||||
|
"command": "cmd=$(jq -r '.tool_input.command // empty'); if printf '%s' \"$cmd\" | grep -qiE '(^|[|;&(]|\\$\\()[[:space:]]*[^|;&[:space:]]*tclsh[0-9.]*(\\.exe)?\"?[[:space:]]+(-encoding[[:space:]]+[^[:space:]]+[[:space:]]+)?-e([[:space:]]|$)'; then printf '%s' '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"tclsh has no -e one-liner flag. An argument starting with - is not treated as a script file: all args land in $argv and tclsh reads commands from stdin instead (hangs forever at an interactive prompt on a console; silently ignores the -e script when stdin is piped). Write the code to a temp .tcl file and run: tclsh path/to/file.tcl - or pipe the script via stdin. See AGENTS.md User Preferences.\"}}'; fi", |
||||||
|
"shell": "bash", |
||||||
|
"timeout": 15, |
||||||
|
"statusMessage": "Checking for tclsh -e misuse" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue