armedbear / abcl

Armed Bear Common Lisp <git+https://github.com/armedbear/abcl/> <--> <svn+https://abcl.org/svn> Bridge
https://abcl.org#rdfs:seeAlso<https://gitlab.common-lisp.net/abcl/abcl>
Other
292 stars 30 forks source link

pathname functions do the wrong thing when faced with actual filename with embedded asterisk <http://abcl.org/trac/ticket/452> #63

Open alanruttenberg opened 7 years ago

alanruttenberg commented 7 years ago

In a shell: touch /tmp/*

(probe-file "/tmp/") ; Evaluation aborted on #<FILE-ERROR {7DF4B809}>. CL-USER> (probe-file "/tmp/\") ; Evaluation aborted on #<FILE-ERROR {4D5E9779}>. CL-USER> (probe-file "/tmp/%2A") nil CL-USER> (probe-file "file:///tmp/%2A") ; Evaluation aborted on #<FILE-ERROR {7DF4B809}>.

The error is: Bad place for a wild pathname.


I had a quick look to see how this could be repaired, but wasn't sure what the right approach is. This stackoverflow answer suggests using "\" as a quote, which is probably the best solution, and would be compatible with what Clozure CL, SBCL and LispWorks do. I also think the percent escaped character should be made to work.

The specific screw case I had was that there was an accidentally created file with a "*" in a directory that was being scanned for ASDF's system registry, which crapped out because the directory function returned the "*" pathname, and subsequently did a probe on the file.

easye commented 7 years ago

The way forward here is to replace the representation of PATHNAME objects with something that explicitly encodes wildcards for DIRECTORY/NAME/TYPE fields "out of bounds" from asterisk characters. This is how SBCL handles things internally.

So, "/tmp/*/private/foo*bar" would be (:directory '(:absolute "tmp" :wild "bar") :name '("foo" :wild "bar").

To be done right, we unfortunately need to clean up Pathname.java and LogicalPathname.java. There is quite a lot to do in that simple goal, for which I [probably need another eight hours][abcl-pathname-refactor.tar.gz].

abcl-pathname-refactor.tar.gz

easye commented 7 years ago

c.f. http://abcl.org/trac/ticket/452