From 707e430bc5e6949d2566207c8da5627514325ac3 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 12 Jan 2024 18:33:22 +0100 Subject: [PATCH] dude --- src/babashka/main.clj | 8 +++++--- test-resources/script_with_overlapping_opts.clj | 1 + test/babashka/main_test.clj | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 test-resources/script_with_overlapping_opts.clj diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 76707089..d7b8052c 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -722,9 +722,10 @@ Use bb run --help to show this help output. (let [opt (first options)] (if (and opt (and (fs/exists? opt) (not (fs/directory? opt)))) - [(next options) (assoc opts-map - (if (str/ends-with? opt ".jar") - :jar :file) opt)] + [nil (assoc opts-map + (if (str/ends-with? opt ".jar") + :jar :file) opt + :command-line-args (next options))] [options opts-map]))) (defn parse-opts @@ -1152,6 +1153,7 @@ Use bb run --help to show this help output. (:jar opts)) (parse-file-opt args opts) [args opts]) + ;; _ (prn :args args :opts opts) abs-path #(-> % io/file .getAbsolutePath) config (cond config (if (fs/exists? config) (abs-path config) diff --git a/test-resources/script_with_overlapping_opts.clj b/test-resources/script_with_overlapping_opts.clj new file mode 100644 index 00000000..796f8250 --- /dev/null +++ b/test-resources/script_with_overlapping_opts.clj @@ -0,0 +1 @@ +(prn (first *command-line-args*)) diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 49177045..4e892fc4 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -1,6 +1,7 @@ (ns babashka.main-test {:clj-kondo/config '{:linters {:unresolved-symbol {:exclude [working?]}}}} (:require + [babashka.fs :as fs] [babashka.main :as main] [babashka.test-utils :as test-utils] [clojure.edn :as edn] @@ -71,7 +72,8 @@ (-> (let [[_ opts] (main/parse-file-opt ["-e" "(prn :foo)"] {})] (main/parse-opts ["-e" "(prn :foo)"] opts))))) (is (= {:file "foo", :command-line-args ["README.md"]} - (main/parse-opts ["README.md"] {:file "foo"}))))) + (main/parse-opts ["README.md"] {:file "foo"}))) + (prn (bb nil (fs/file "test-resources" "script_with_overlapping_opts.clj") "--version")))) (deftest version-test (is (= [1 0 0] (main/parse-version "1.0.0-SNAPSHOT")))