Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs/match won't find things in root-folder #117

Closed
eval opened this issue Oct 10, 2023 · 1 comment · Fixed by #118
Closed

fs/match won't find things in root-folder #117

eval opened this issue Oct 10, 2023 · 1 comment · Fixed by #118

Comments

@eval
Copy link
Contributor

eval commented Oct 10, 2023

$ docker run -it babashka/babashka bash -c 'touch tmp/testing.txt && bb -e '"'"'(prn (fs/glob "/tmp" "testing.txt"))'"'"''
[#object[sun.nio.fs.UnixPath 0x5013f6b "/tmp/testing.txt"]]
$ docker run -it babashka/babashka bash -c 'touch testing.txt && bb -e '"'"'(prn (fs/glob "." "testing.txt"))'"'"''
[]
# expected: [#object[sun.nio.fs.UnixPath ,,, "/testing.txt"]] because:
$ docker run -it babashka/babashka bash -c 'touch testing.txt && bb -e '"'"'(prn (fs/exists? (fs/path "/testing.txt")))'"'"''
true

Cause seems to be that the base-path is always appended with file-separator, so when base-path is / we end up with pattern //testing.txt instead of /testing.txt:

fs/src/babashka/fs.cljc

Lines 282 to 288 in aa0f8bc

pattern (str base-path
;; we need to escape the file separator on Windows
(when win? "\\")
file-separator
(if win?
(str/replace pattern "/" "\\\\")
pattern))

@borkdude
Copy link
Contributor

@eval Fix welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants