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.7 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).

Notes

  • G-118 relationship (recorded 2026-07-24 after overlap review; achieved 2026-07-25 - see goals/archive/G-118-tclsh-subcommand-review.md): G-118 settled the stock leading-dash fallthrough this goal must not disturb - <punkexe> tclsh -e ... deliberately keeps stock's -e misparse (stock parity is the tclsh subcommand's contract); the one-liner instinct is served only at the top level and via script -e. Its item-10 definitions state this boundary in the tclsh @cmd help (punk::args::moduledoc::punkexe, id (script)::punkexe::tclsh) - when this goal lands the top-level/script -e forms, update that boundary text to point at the live forms.