ccl icon indicating copy to clipboard operation
ccl copied to clipboard

Improper handling of pathname-name for dotfiles

Open kingcons opened this issue 1 year ago • 4 comments

A test case is as follows:

(defvar *example* #p"/home/cons/projects/collards/examples/.collards")
(pathname-name *example*) ;; returns NIL
(pathname-type *example*) ;; returns "collards"

This causes an incorrect result from uiop:hidden-pathname-p. (see: https://gitlab.common-lisp.net/asdf/asdf/-/blob/master/uiop/pathname.lisp#L257)

I don't claim that this is in violation of the standard, but it seems to be the opposite interpretation to all three other implementations I tested: clisp, ecl, and sbcl.

kingcons avatar Oct 08 '24 02:10 kingcons

If anything,

CL-USER> (make-pathname :directory '(:absolute "foo" "bar") :name ".baz")
#P"/foo/bar/\\.baz"

So the issue is in how CCL parses and prints unix-like namestrings differently than other implementations (note the extra slash in the namestring; IIUC it is there to show that the dot is a part of the name, not the type) and not in how an already cooked pathname works with regards to uiop:hidden-pathname-p.

Maybe the TODO at https://github.com/Clozure/ccl/blob/24c25528be069d78473d76d1fa135845ddfe41cd/level-1/l1-files.lisp#L1004 is a hint towards this?

phoe avatar Oct 08 '24 07:10 phoe

I sincerely don't know what the right thing is.

An older LispWorks I have installed says

(pathname-name *example*) ;; returns ""
(pathname-type *example*) ;; returns "collards"

The comment by @phoe shows an instance of CCL's namestring quoting. To be honest, I've been wondering for a long time whether CCL should stop doing this. See #42.

xrme avatar Oct 15 '24 19:10 xrme

On the other hand, LW 8.0.1 Personal says:

CL-USER 1 > (describe (make-pathname :directory '(:absolute "foo" "bar") :name ".baz"))

#P"/foo/bar/.baz" is a PATHNAME
HOST           NIL
DEVICE         NIL
DIRECTORY      (:ABSOLUTE "foo" "bar")
NAME           ".baz"
TYPE           NIL
VERSION        NIL

CL-USER 2 > (describe (make-pathname :directory '(:absolute "foo" "bar") :type "baz"))

#P"/foo/bar/.baz" is a PATHNAME
HOST           NIL
DEVICE         NIL
DIRECTORY      (:ABSOLUTE "foo" "bar")
NAME           NIL
TYPE           "baz"
VERSION        NIL

Notice the ambiguous namestring.

phoe avatar Oct 15 '24 19:10 phoe

You mention LW 8.0.1 Personal, so perhaps you’re only interested in implementation specific behavior, but note that a dot in a pathname component is NOT conforming.

Even lower case is dubious; it can be acceptable when :case :local is assumed, but it then depends on the underlying file systems. For example, no implementation implement :case :local correctly IMO, since none take into account the customary case of the file system where the component is stored, taking into account that you can mount file system on file systems, so the customary case can be different for different components of the same pathname!

If you want to use maximally portable and conforming logical pathnames, use only uppercase ASCII letters and digits and the underline character in component names. (Note: even the dash is not maximally portable and conforming!)

On 15 Oct 2024, at 21:39, phoe @.***> wrote:

On the other hand, LW 8.0.1 Personal says:

CL-USER 1 > (describe (make-pathname :directory '(:absolute "foo" "bar") :name ".baz"))

#P"/foo/bar/.baz" is a PATHNAME HOST NIL DEVICE NIL DIRECTORY (:ABSOLUTE "foo" "bar") NAME ".baz" TYPE NIL VERSION NIL

CL-USER 2 > (describe (make-pathname :directory '(:absolute "foo" "bar") :type ".baz"))

#P"/foo/bar/..baz" is a PATHNAME HOST NIL DEVICE NIL DIRECTORY (:ABSOLUTE "foo" "bar") NAME NIL TYPE ".baz" VERSION NIL Notice the double period in the namestring.

— Reply to this email directly, view it on GitHub https://github.com/Clozure/ccl/issues/521#issuecomment-2414857455, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGBJDD7N3MC626VFUN7LFLZ3VVOFAVCNFSM6AAAAABPREJX76VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJUHA2TONBVGU. You are receiving this because you are subscribed to this thread.

informatimago avatar Oct 16 '24 19:10 informatimago