mirror of https://github.com/Hilbis/Hilbish
fix: dont go interactive if not terminal (closes #48)
parent
7e970e9e81
commit
1623f0d85d
12
main.go
12
main.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
@ -61,6 +62,10 @@ func main() {
|
|||
interactive = true
|
||||
}
|
||||
|
||||
if fileInfo, _ := os.Stdin.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
|
||||
interactive = false
|
||||
}
|
||||
|
||||
if getopt.NArgs() > 0 {
|
||||
interactive = false
|
||||
}
|
||||
|
@ -115,6 +120,13 @@ func main() {
|
|||
|
||||
lr = NewLineReader("")
|
||||
|
||||
if fileInfo, _ := os.Stdin.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
|
||||
scanner := bufio.NewScanner(bufio.NewReader(os.Stdin))
|
||||
for scanner.Scan() {
|
||||
RunInput(scanner.Text())
|
||||
}
|
||||
}
|
||||
|
||||
if *cmdflag != "" {
|
||||
RunInput(*cmdflag)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue