Redirect stdin to PTY for terminal size queries

Use `<>$ptyPath >&0 2>&0` to connect all three fds (stdin/stdout/stderr)
to the PTY slave, so scripts can query terminal dimensions via stty size.

Made-with: Cursor
This commit is contained in:
LoveSy
2026-03-04 23:00:48 +08:00
committed by topjohnwu
parent 741eff8c50
commit b89589ee0c
2 changed files with 2 additions and 2 deletions
@@ -190,7 +190,7 @@ class FlashViewModel : BaseViewModel() {
"sh $dir/update-binary dummy 1 '${zipFile.absolutePath}'; " +
"EXIT=\$?; " +
"if [ \$EXIT -ne 0 ]; then echo '! Installation failed'; fi; " +
"exit \$EXIT) >$ptyPath 2>&1"
"exit \$EXIT) <>$ptyPath >&0 2>&0"
).exec().isSuccess
}
@@ -70,7 +70,7 @@ class ActionViewModel : BaseViewModel() {
val success = withContext(Dispatchers.IO) {
Shell.cmd(
"(export TERM=xterm-256color; run_action '$actionId') >$ptyPath 2>&1"
"(export TERM=xterm-256color; run_action '$actionId') <>$ptyPath >&0 2>&0"
).exec().isSuccess
}