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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -61,6 +62,10 @@ func main() {
|
||||||
interactive = true
|
interactive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fileInfo, _ := os.Stdin.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
|
||||||
|
interactive = false
|
||||||
|
}
|
||||||
|
|
||||||
if getopt.NArgs() > 0 {
|
if getopt.NArgs() > 0 {
|
||||||
interactive = false
|
interactive = false
|
||||||
}
|
}
|
||||||
|
@ -115,6 +120,13 @@ func main() {
|
||||||
|
|
||||||
lr = NewLineReader("")
|
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 != "" {
|
if *cmdflag != "" {
|
||||||
RunInput(*cmdflag)
|
RunInput(*cmdflag)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue