mirror of https://github.com/Hilbis/Hilbish
fix(readline): check stdin error properly
parent
bee8d6e9e6
commit
b83c09a2b3
|
@ -2,6 +2,7 @@ package readline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -78,9 +79,7 @@ func (rl *Instance) Readline() (string, error) {
|
||||||
var err error
|
var err error
|
||||||
i, err = os.Stdin.Read(b)
|
i, err = os.Stdin.Read(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// i shouldnt really check the error like this but i dont know what
|
if errors.Is(err, syscall.EAGAIN) {
|
||||||
// the actual thing is so
|
|
||||||
if err.Error() == "read /dev/stdin: resource temporarily unavailable" {
|
|
||||||
err = syscall.SetNonblock(syscall.Stdin, false)
|
err = syscall.SetNonblock(syscall.Stdin, false)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue