In short: it starts the program with the given arguments, adding JJ_WORKSPACE_ROOT to its environment
when a workspace was found, waits for it, and exits with the same code. It never loads the repo and never
snapshots. Upstream's help warns that it is "a convenient syntax for running arbitrary code on your system"
(source).
The command is cmd_util_exec. Its help text: "Execute an
external command via jj" (source). It is the Exec variant of
UtilCommand (source, dispatch).
1. Command-line surface
| Argument | Type | Default | Meaning |
|---|---|---|---|
COMMAND (positional, required) | string | none | "External command to execute" (source). |
ARGS… (positional) | strings | none | "Arguments to pass to the external command" (source). |
The intended use is an alias such as my-script = ["util", "exec", "--", "my-jj-script"]; the
-- makes jj pass the script's flags through instead of parsing them (source).
The global flags are on the CLI page.
3. End-to-end flow
4. Core architecture touchpoints
| Piece | Role here |
|---|---|
CommandHelper::workspace_loader | Only used to find the workspace root; an error just means no JJ_WORKSPACE_ROOT (source, test). |
| The process exit | A child's exit code becomes jj's own through std::process::exit, skipping jj's usual error reporting. So a child's clap error exits 2 with only the child's message (test). |
| Repo, working copy, operation log | Not touched by jj itself; the child may run jj, which then snapshots as usual. |