From 3a50b451409d12ad9f7d1b38ac930bd01d4486d0 Mon Sep 17 00:00:00 2001 From: sammyette Date: Sat, 6 Apr 2024 18:28:05 -0400 Subject: [PATCH] fix: check if no tty after line read and halt after error use an empty channel to stop without panicing --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 2b92e37..d2eef51 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "errors" "fmt" "io" "os" @@ -9,6 +10,7 @@ import ( "path/filepath" "runtime" "strings" + "syscall" "hilbish/util" "hilbish/golibs/bait" @@ -189,9 +191,12 @@ input: } else { // If we get a completely random error, print fmt.Fprintln(os.Stderr, err) + if errors.Is(err, syscall.ENOTTY) { + // what are we even doing here? + panic("not a tty") + } } - // TODO: Halt if any other error occurs - continue + <-make(chan struct{}) } var priv bool if strings.HasPrefix(input, " ") {