Skip to content

feat(commands): add vim-style shell execution - #338

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/ex-shell
Aug 24, 2026
Merged

fcoury-oai merged 1 commit into
mainfrom
fcoury/ex-shell

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Why

Vim users expect :!{command} to run shell commands without leaving their editor. Red previously had no editor-owned shell execution path, and handing a terminal to a subprocess would break its responsive UI and detachable sessions.

What Changed

  • Add asynchronous :!{command} and :!! execution through the user's shell, including pipelines, %/# filename expansion, previous-command expansion, and escaped special characters.
  • Stream bounded, sanitized stdout/stderr into Messages, surface exit failures, support Ctrl-c cancellation, and keep shell jobs alive when detached clients disconnect.
  • Preserve security and file-safety boundaries: shell actions cannot be deserialized or invoked through plugins, agents, or :bufdo; shell command bodies are redacted from logs; external file changes still respect dirty-buffer conflict protection.
  • Document the supported shell subset and explicitly exclude interactive programs, :read !, :write !, and range filters such as :%!sort.

How to Test

  1. Open Red with any file and enter :!printf 'hello world' | tr a-z A-Z. Confirm Messages opens, displays HELLO WORLD, reports success, and leaves the current buffer unchanged.
  2. Press Esc, run :!!, and confirm the previous command executes again. Then run :!sleep 30, press Ctrl-c in Messages, and confirm the command is cancelled while the editor remains responsive.
  3. Run CARGO_TARGET_DIR=/private/tmp/red-ex-shell-target cargo test --test editing shell_command_ to exercise command expansion, stdout/stderr, failure reporting, bounded output, cancellation, security boundaries, and dirty-buffer protection.
  4. Run CARGO_TARGET_DIR=/private/tmp/red-ex-shell-target cargo test --test detach shell_command_survives_disconnect_without_blocking_detach_ipc and confirm the shell process survives client disconnect without blocking detached-session IPC.

@fcoury-oai
fcoury-oai merged commit f5cff19 into main Aug 24, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/ex-shell branch August 24, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant