Compare commits

...

2 Commits

Author SHA1 Message Date
sammy 75d7c6acc6
chore: bump version 2021-05-01 10:51:00 -04:00
sammy 96600398b7
fix: dont be interactvive if source is provided
hilbish wont go into an interactive mode if its provided
a lua source file to run, even if -i is passed.
i feel like this makes the most sense.
2021-05-01 10:44:15 -04:00
1 changed files with 9 additions and 4 deletions

13
main.go
View File

@ -16,7 +16,7 @@ import (
"golang.org/x/term"
)
const version = "0.4.0-dev.5"
const version = "0.4.0-dev.6"
var (
l *lua.LState
@ -49,13 +49,16 @@ func main() {
_ = getopt.BoolLong("interactive", 'i', "Force Hilbish to be an interactive shell")
getopt.Parse()
args := getopt.Args()
interactiveflag := getopt.Lookup('i').Seen()
if *cmdflag == "" || interactiveflag {
interactive = true
}
if getopt.NArgs() > 0 {
interactive = false
}
if *verflag {
fmt.Printf("Hilbish v%s\n", version)
os.Exit(0)
@ -97,11 +100,13 @@ func main() {
readline.LoadHistory(homedir + "/.hilbish-history")
RunInput(*cmdflag)
if len(args) > 0 {
err := l.DoFile(args[0])
if getopt.NArgs() > 0 {
err := l.DoFile(getopt.Arg(0))
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
os.Exit(0)
}
for interactive {