Skip to content

implement exec as non-replacing command execution #797

@chaliy

Description

@chaliy

Problem

exec is intentionally excluded (TM-ESC-005) because it cannot replace the shell process in a sandbox. However, exec is commonly used in scripts to hand off to another command as the final action, and the current behavior (silent failure or error) breaks real-world scripts.

Impact

Scripts that use exec for plugin dispatch or command delegation fail entirely. Example from wedow/ticket (line 1351):

exec "$_plugin" "$@"

This is the plugin system's dispatch mechanism — without it, tk list, tk query, tk edit, and all plugin commands are broken.

Proposal

Implement exec as "run the command and exit with its exit code" — which is semantically equivalent in a sandboxed environment where there's no real process to replace:

exec some_command args...
# Equivalent to:
some_command args...
exit $?

This preserves the security invariant (no process replacement / sandbox escape) while supporting the common exec usage pattern. The exec with only redirections (exec 3>file) can remain unsupported or be a separate follow-up.

Security notes

  • No actual process replacement — just run + exit
  • FD-only exec (no command) can error explicitly
  • Stays within sandbox containment (TM-ESC-005)
  • Document the difference from real exec in specs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions