Skip to content

Shell escape: pipe stdin for interactive native commands #567

Description

@stalep

Summary

When shell escape (!command) is used to run an interactive native command that reads from stdin (e.g., a .bat file with pause or set /p, or Unix commands like less, vim, python), the command hangs because the current implementation does not connect the terminal's input to the process's stdin.

Current behavior

The executeNativeCommand() method in ReadlineConsole reads the process's stdout and pipes it through Connection.write(), but does NOT connect the connection's input to the process's stdin. Interactive commands that need user input block indefinitely.

Expected behavior

Interactive native commands should receive terminal input:

[myshell]$ !python
Python 3.12.0
>>> print("hello")
hello
>>> exit()
[myshell]$

Proposed approach

  1. Temporarily redirect the connection's stdin handler to write to the process's stdin stream
  2. Continue reading the process's stdout and writing to the connection
  3. Handle Ctrl-C by destroying the native process and returning to the aesh prompt
  4. Restore the original stdin handler when the process completes

Alternative: inheritIO() — for local terminals, ProcessBuilder.inheritIO() supports fully interactive programs but does NOT work for remote connections (SSH, WebSocket). Could auto-detect local vs remote.

Context

Follow-up to #566 (shell escape via ! prefix).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions