You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2.0 KiB

G-077 punk executable -e one-liner support: make the tclsh-agent instinct work

Status: proposed Scope: src/vfs/_config/punk_main.tcl (top-level arg dispatch), src/lib/app-punkscript/punkscript.tcl (script subcommand arg forms), src/tests/shell/testsuites/punkexe/scriptexec.test Goal: <punkexe> -e <script> ?args...? and <punkexe> script -e <script> ?args...? execute the given Tcl code as a one-liner (args after the script land in ::argv, ::argv0 = -e, non-interactive), so the -e reflex agents carry over from perl/python/node works on punk kits instead of erroring - while stock-tclsh misparse behaviour (argv-swallow + stdin read) is never reproduced. Acceptance: punksys -e {puts hi} and punk902z script -e {puts hi} print hi and exit 0 with and without piped stdin present (the one-liner may itself read stdin); a -e with no following script argument is a usage error, never an interactive fall-through; error in the one-liner prints errorInfo to stderr and exits 1 (matching the script subcommand's file form); scriptexec.test covers the above against the built executable.

Context

Agents and harnesses habitually try tclsh -e "script" (the one-liner reflex from perl/python/node). Stock tclsh has no such flag: only -encoding name is recognised, and any other leading-dash argument is not treated as a script file - all arguments land in $argv and tclsh reads commands from stdin instead (hangs at an interactive prompt on a console; silently ignores the supposed one-liner when stdin is piped). Root AGENTS.md User Preferences documents the pitfall and a claude-harness PreToolUse hook (.claude/settings.json) denies such invocations with corrective guidance.

The punk kits currently fail fast instead (punk script: script file not found: '-e') but offer no one-liner form. This goal makes the instinct work on punk executables, removing the failure class for the kits entirely. app-punkscript's existing stdin form already provides the execution scaffolding (argv0/argv setup, errorInfo-to-stderr, exit-code discipline).