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.
pull/45/head
sammy 2021-05-01 10:44:15 -04:00
parent 88d9f2e21d
commit 96600398b7
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 8 additions and 3 deletions

11
main.go
View File

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