From 96600398b7381bfb4ea5cb0d56f1452a4bbbf0eb Mon Sep 17 00:00:00 2001 From: sammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sat, 1 May 2021 10:44:15 -0400 Subject: [PATCH] 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. --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index d4da784..3687caf 100644 --- a/main.go +++ b/main.go @@ -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 {