catch exceptions from resolving symbolic links during bb.edn lookup (#1702)

This commit is contained in:
Bob 2024-06-08 14:56:07 -04:00 committed by GitHub
parent ea2c3f06ec
commit c3c0bf3cef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View file

@ -19,6 +19,7 @@ A preview of the next release can be installed from
- [#1696](https://github.com/babashka/babashka/issues/1696): add `clojure.core/*source-path*` (points to the same sci var as `*file*`) ([@bobisageek](https://github.com/bobisageek))
- [#1696](https://github.com/babashka/babashka/issues/1696): add `clojure.main/with-read-known` ([@bobisageek](https://github.com/bobisageek))
- [#1696](https://github.com/babashka/babashka/issues/1696): add `clojure.core.server/repl-read` ([@bobisageek](https://github.com/bobisageek))
- [#1700](https://github.com/babashka/babashka/issues/1700): catch exceptions from resolving symbolic links during `bb.edn` lookup ([@bobisageek](https://github.com/bobisageek))
## 1.3.190 (2024-04-17)

View file

@ -1149,7 +1149,10 @@ Use bb run --help to show this help output.
(defn resolve-symbolic-link [f]
(if (and f (fs/exists? f))
(str (fs/real-path f))
(try
(str (fs/real-path f))
(catch Exception _
f))
f))
(defn deps-not-needed [opts]

View file

@ -531,6 +531,12 @@ even more stuff here\"
(testing "symlink"
(is (= {1 {:id 1}} (bb (str (fs/file "test-resources" "symlink-adjacent-bb")))))))
; symlinks that resolve in the /proc fs cause fs/real-path to throw when figuring out bb.edn path (issue #1700)
(deftest redirection-test
(testing "main doesn't throw when input file symlink resolves to 'not real' file"
(when (and test-utils/native? (not test-utils/windows?))
(is (str/starts-with? (test-utils/bb "(println \"hi\")" "/dev/stdin") "hi")))))
(deftest non-existing-tasks-in-run-gives-exit-code-1
(is (thrown? Exception (bb "-Sdeps" "{:tasks {foo {:task (run (quote bar))}}}" "foo"))))