mirror of https://github.com/Hilbis/Hilbish
fix: tty checks (#284)
parent
11323a70aa
commit
b416264138
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -1,14 +1,19 @@
|
|||
# 🎀 Changelog
|
||||
|
||||
## Unreleased
|
||||
## Added
|
||||
### Fixed
|
||||
- Do more checks for a TTY
|
||||
- Panic if ENOTTY is thrown from readline
|
||||
- use `x/term` function to check if a terminal
|
||||
|
||||
### Added
|
||||
- Page Up/Down keybinds for Greenhouse will now scroll up and down the size of the region (a page)
|
||||
|
||||
## Changed
|
||||
### Changed
|
||||
- Remove usage of `hilbish.goro` in Greenhouse.
|
||||
|
||||
## [2.2.1] - 2023-12-26
|
||||
## Fixed
|
||||
### Fixed
|
||||
- Removed a left over debug print
|
||||
- Recover panic in `hilbish.goro`
|
||||
|
||||
|
|
11
main.go
11
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"
|
||||
|
@ -88,7 +90,7 @@ func main() {
|
|||
interactive = true
|
||||
}
|
||||
|
||||
if fileInfo, _ := os.Stdin.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
|
||||
if fileInfo, _ := os.Stdin.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 || !term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
interactive = false
|
||||
}
|
||||
|
||||
|
@ -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, " ") {
|
||||
|
|
Loading…
Reference in New Issue