Skip to main content

Module shell_exec

Module shell_exec 

Source
Expand description

Suspend/resume subprocess execution.

Implements the suspend/resume sequence from the architecture doc §3:

  1. Leave alternate screen and restore cooked terminal mode.
  2. Spawn the subprocess with inherited stdio, relative to cwd.
  3. Wait for the subprocess to exit.
  4. Re-enter raw mode and the alternate screen.
  5. Signal the caller that a full redraw is required (the subprocess may have overwritten the terminal).

The same path serves both “open in configured editor” and Command Mode’s !<shell command> — the only difference is the argv passed in.

For the command forms that need an interpreter (!<command> and :git), shell_argv builds that argv from the [general] shell config key, so which shell runs them is the user’s choice rather than a compile-time constant.

Enums§

ShellExecError
Errors that can arise while running an external process.
ShellPause
When Trail prints the result block and waits for a key before reclaiming the screen from a command.

Constants§

DEFAULT_SHELL_ARGV
Interpreter used for !<command> and :git when [general] shell is blank.

Functions§

run_external
Leaves the alternate screen, runs argv in cwd, then restores the TUI.
shell_argv
Builds the argv that runs command through the shell named by spec.
split_shell_spec
Splits a [general] shell spec into the argv prefix it stands for.