Fix #1575: command line parsing problem with -e + *command-line-args*

This commit is contained in:
Michiel Borkent 2023-06-11 11:11:10 +02:00
parent c3cf8f5330
commit 7b7feb7034
3 changed files with 43 additions and 39 deletions

View file

@ -7,9 +7,9 @@ A preview of the next release can be installed from
[Babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting [Babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting
[Babashka-conf](https://babashka.org/conf/) is happening June 10th in ## Unreleased
Berlin. Save the date and/or submit your babashka/clojure-related talk or workshop
in the CfP! - #1575: fix command line parsing problem with `-e` + `*command-line-args*`
## 1.3.180 (2023-05-28) ## 1.3.180 (2023-05-28)

View file

@ -729,7 +729,7 @@ Use bb run --help to show this help output.
:jar :file) opt :jar :file) opt
:command-line-args (next options))] :command-line-args (next options))]
opts) opts)
(assoc opts-map :command-line-args options)))) opts-map)))
(defn parse-opts (defn parse-opts
([options] (parse-opts options nil)) ([options] (parse-opts options nil))

View file

@ -65,7 +65,11 @@
(is (= {:force? true :run "sometask" :command-line-args nil} (parse-opts ["--force" "run" "sometask"]))) (is (= {:force? true :run "sometask" :command-line-args nil} (parse-opts ["--force" "run" "sometask"])))
(is (= {:force? true :repl true} (parse-opts ["--force" "repl"]))) (is (= {:force? true :repl true} (parse-opts ["--force" "repl"])))
(is (= {:force? true :clojure true :command-line-args '("-M" "-r")} (is (= {:force? true :clojure true :command-line-args '("-M" "-r")}
(parse-opts ["--force" "clojure" "-M" "-r"])))) (parse-opts ["--force" "clojure" "-M" "-r"])))
(testing "file opts parsing does not mess with :command-line-args"
(is (= {:prn true, :expressions ["(prn :foo)"]}
(-> (let [opts (main/parse-file-opt ["-e" "(prn :foo)"] {})]
(main/parse-opts ["-e" "(prn :foo)"] opts)))))))
(deftest version-test (deftest version-test
(is (= [1 0 0] (main/parse-version "1.0.0-SNAPSHOT"))) (is (= [1 0 0] (main/parse-version "1.0.0-SNAPSHOT")))
@ -880,7 +884,7 @@ true")))
(is (= 1 (bb nil "(.indexOf (map inc [1 2 3]) 3)")))) (is (= 1 (bb nil "(.indexOf (map inc [1 2 3]) 3)"))))
(deftest get-watches-test (deftest get-watches-test
(is (true? (bb nil "(map? (.getWatches (doto (atom nil) (add-watch :foo (fn [k r o n])))))" )))) (is (true? (bb nil "(map? (.getWatches (doto (atom nil) (add-watch :foo (fn [k r o n])))))"))))
;;;; Scratch ;;;; Scratch