Skip to content

10 — Shell Execution

Two modes of shell execution in String.

/execbash:name
StateNone (stateless)Full shell state
cwdDocument dir or homeCumulative
Envbase + {var}Cumulative
Use caseQuick one-shotLong-running work
  • Syntax: /exec <command>
  • Spawns a new /bin/bash -c process every time
  • cwd: current document directory → falls back to home if no document open
  • env: process.env + session variables ({var}) exported as environment variables
    • Variables starting with _ (config variables) are excluded
  • Timeout: 30 seconds
  • stderr + stdout merged into single output
  • Empty input → COMMAND_UNSUPPORTED error

Everything after /exec is passed verbatim to bash -c. Write commands as you would type them in a terminal — do NOT wrap the whole command in quotes.

/exec pwd ✅ single command
/exec pwd; echo '---'; ls -la ✅ chained commands
/exec for f in *.md; do wc -l "$f"; done ✅ shell constructs work
/exec echo $HOME ✅ shell variables expand normally
/exec "pwd; echo test" ❌ quotes become part of the command
→ bash tries to run literal "pwd; echo test"
→ EXIT_127 (command not found)

⚠️ Meta-commands in bash sessions use // prefix.

  • Correct: //help, //info, //close
  • Incorrect: /help (may be sent to bash and fail)
  • Topic scheme: bash:name (ChanFlow: <𝒞=string:bash:name>)
  • All input is sent to shell stdin — plain text works as-is (no / prefix needed)
  • // prefix → String meta-command (//help, //info, //close)
  • State preserved: cwd, env vars, shell history
echo hello ✅ plain text → shell stdin
/bin/echo hello ✅ absolute path → shell stdin
cd /tmp && pwd ✅ chained commands
//help ✅ String meta-command
//close ✅ String meta-command
/help ❌ sent to bash as-is → "bash: /help: No such file or directory"
exit: N | cwd: /path
---
output here
  • exit: 0ok: true
  • exit: non-zerook: false

Both modes export session {var} as environment variables:

  • {MY_VAR}MY_VAR=value in env
  • Variables starting with _ are excluded (config/internal)
  • $var (runtime variables) are never exported