diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 377f1527..88a9a97b 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -481,8 +481,10 @@ Use -- to separate script command line args from bb command line args. (assoc opts-map :main (first options)))) (":do") (let [options (next options) - options (into [] (comp (partition-by #(or (= % ":and-do") - (= % ":or-do")))) + options (into [] (comp (partition-by #(or + (= % ":do") + (= % ":and-do") + (= % ":or-do")))) options)] {:do options}) (":invoke") @@ -738,13 +740,15 @@ Use -- to separate script command line args from bb command line args. (let [opts (parse-opts args)] (if-let [do-opts (:do opts)] (reduce (fn [prev-exit opts] + ;; (prn :prev prev-exit) + ;; (prn :opts opts) (if (pos? prev-exit) (case opts - [":or-do"] 0 + ([":do"] [":or-do"]) 0 ;; skipping, returning 0 (reduced prev-exit)) (case opts [":or-do"] (reduced prev-exit) ;; short-cutting - [":and-do"] 0 ;; skipping, returning 0 + ([":do"] [":and-do"]) 0 ;; skipping, returning 0 (exec (parse-opts opts))))) 0 do-opts) diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index ef42fd09..256cd594 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -48,6 +48,21 @@ (let [res (bb :all)] (is (= 6 res))) (is (not (fs/exists? temp-file)))))) + (testing ":do always continuing" + (with-config {:tasks {:sum-1 {:task/type :babashka + :args ["-e" "(do (+ 4 5 6) nil)"]} + :sum-2 {:task/type :babashka + :args ["-e" "(+ 1 2 3)"]} + :all {:task/type :babashka + :args [:do :sum-1 :do :sum-2]}}} + (is (= 6 (bb :all)))) + (with-config {:tasks {:div-by-zero {:task/type :babashka + :args ["-e" "(/ 1 0)"]} + :sum {:task/type :babashka + :args ["-e" "(+ 1 2 3)"]} + :all {:task/type :babashka + :args [:do :div-by-zero :do :sum]}}} + (is (= 6 (bb :all))))) (testing ":and-do failing" (with-config {:tasks {:div-by-zero {:task/type :babashka :args ["-e" "(/ 1 0)"]}