Skip to content

runok exec

runok exec evaluates a command against your runok rules and, if allowed, executes it — optionally within a sandbox. If the command is denied (or requires confirmation), it is not executed and exit code 3 is returned.

Terminal window
runok exec [options] -- <command> [arguments...]

The -- separator distinguishes runok flags from the command’s own flags. Any unrecognized flag before -- is rejected with an error to prevent typos from being silently absorbed into the command arguments.

A single argument after -- is interpreted as a shell command (passed to the shell). Multiple arguments are interpreted as an argv array (executed directly).

Apply a named sandbox preset from your runok configuration. Overrides any sandbox defined in the matching rule.

Show what would happen without executing the command. Prints diagnostic information to stderr and always exits with code 0.

Output detailed rule matching information to stderr.

Execute a command with permission checks:

Terminal window
runok exec -- npm test

Execute with a sandbox preset:

Terminal window
runok exec --sandbox strict -- npm install

Preview what would happen without executing:

Terminal window
runok exec --dry-run -- git push --force

Run a shell expression (single argument, passed to shell):

Terminal window
runok exec -- 'echo hello && echo world'
CodeMeaning
NCommand’s own exit code (on successful execution).
1An error occurred (config error, sandbox setup failure, etc.).
3Command was denied or requires confirmation (ask).