fix: terminal hangs, right arrow blocking, and runaway iris processes (#142)
closes #137 - right arrow consumed the escape sequence without forwarding it, so the cursor couldn't move back right after moving left (60149a2) - p10k's instant prompt redirects stdout to a temp file that exec iris inherits, sending the overlay there instead of the terminal and looking like a dead keyboard. Reopens /dev/tty when stdout isn't a terminal (7ebbb0c) - zsh/bash autostart lacked the interactivity check fish already had, so agentic tools sourcing your rc file spawned a rogue iris that seized /dev/tty (5fe58be)
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package root
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func captureInitScript(t *testing.T, shell string) string {
|
||||
t.Helper()
|
||||
|
||||
r, w, err := os.Pipe()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
original := os.Stdout
|
||||
os.Stdout = w
|
||||
initCmd.Run(initCmd, []string{shell})
|
||||
_ = w.Close()
|
||||
os.Stdout = original
|
||||
|
||||
out, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// a tool runner that sources the rc file in a non-interactive shell must not
|
||||
// exec a second iris, which would seize the tty from the one already running
|
||||
func TestInitAutostartRequiresInteractiveShell(t *testing.T) {
|
||||
guards := map[string]string{
|
||||
"zsh": "[[ -o interactive ]]",
|
||||
"bash": "[[ $- == *i* ]]",
|
||||
"fish": "status is-interactive",
|
||||
}
|
||||
|
||||
for shell, guard := range guards {
|
||||
t.Run(shell, func(t *testing.T) {
|
||||
script := captureInitScript(t, shell)
|
||||
|
||||
head, _, found := strings.Cut(script, "exec iris")
|
||||
if !found {
|
||||
t.Fatalf("%s init script has no autostart", shell)
|
||||
}
|
||||
|
||||
cond := strings.LastIndex(head, "\nif ")
|
||||
if cond < 0 {
|
||||
t.Fatalf("%s autostart is not inside an if", shell)
|
||||
}
|
||||
|
||||
if !strings.Contains(head[cond:], guard) {
|
||||
t.Fatalf("%s autostart is not guarded by %q:\n%s", shell, guard, head[cond:])
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user