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
- Temporarily redirect the connection's stdin handler to write to the process's stdin stream
- Continue reading the process's stdout and writing to the connection
- Handle Ctrl-C by destroying the native process and returning to the aesh prompt
- 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).
Summary
When shell escape (
!command) is used to run an interactive native command that reads from stdin (e.g., a.batfile withpauseorset /p, or Unix commands likeless,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 inReadlineConsolereads the process's stdout and pipes it throughConnection.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:
Proposed approach
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).