mirror of https://github.com/Hilbis/Hilbish
fix: check if no tty after line read and halt after error
use an empty channel to stop without panicingpull/284/head
parent
20761e754c
commit
3a50b45140
9
main.go
9
main.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -9,6 +10,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"hilbish/util"
|
"hilbish/util"
|
||||||
"hilbish/golibs/bait"
|
"hilbish/golibs/bait"
|
||||||
|
@ -189,9 +191,12 @@ input:
|
||||||
} else {
|
} else {
|
||||||
// If we get a completely random error, print
|
// If we get a completely random error, print
|
||||||
fmt.Fprintln(os.Stderr, err)
|
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
|
var priv bool
|
||||||
if strings.HasPrefix(input, " ") {
|
if strings.HasPrefix(input, " ") {
|
||||||
|
|
Loading…
Reference in New Issue