Giter Site home page Giter Site logo

Bug in PATHNAME-AS-DIRECTORY about cl-fad HOT 5 CLOSED

edicl avatar edicl commented on August 22, 2024
Bug in PATHNAME-AS-DIRECTORY

from cl-fad.

Comments (5)

Devon7 avatar Devon7 commented on August 22, 2024

(list :software (list (software-type) (software-version))
:implementation (list (lisp-implementation-type) (lisp-implementation-version))
:machine (machine-type)) =>
(:SOFTWARE ("Darwin" "18.7.0")
:IMPLEMENTATION ("Clozure Common Lisp" "Version 1.12.1 (v1.12.1) DarwinX8664")
:MACHINE "x86_64")

from cl-fad.

stassats avatar stassats commented on August 22, 2024

I don't think ~ is defined, it's an implementation specific thing.

from cl-fad.

Devon7 avatar Devon7 commented on August 22, 2024

No input, defined or not, legal or not, should produce illegal output such as a "" directory component.
CL-FAD exists because everything to do with pathnames is implementation specific.
By widespread convention ~ is the user's home directory - follow the rule of least surprise.
#+CCL (setq pathspec (pathname pathspec)) seems to fix it in CCL,
now it runs (fad:walk-directory "~" …) ok but that's no stress test.
CCL does

	(pathname-name "~") => "~"
	(pathname-name #P"~") => NIL
	(pathname-name (pathname "~")) => NIL

therefore

	(fad:directory-pathname-p "~") => NIL
	(fad:directory-pathname-p #P"~") => #P"/Users/devon/"
	(fad:directory-pathname-p (pathname "~")) => #P"/Users/devon/"

which smells buggy to me, I'll grovel their sources and maybe talk to them too.

from cl-fad.

stassats avatar stassats commented on August 22, 2024

fad is a portability layer, ~ is not portable, so how it works is moot.

from cl-fad.

Devon7 avatar Devon7 commented on August 22, 2024

The current behavior is compatible with filesystems that allow zero length names.
All others would prefer to signal an error rather than poison the caller with time bombs, e.g.,

(ccl:advise fad:pathname-as-directory
	    (let ((dir (:do-it)))
	      (assert (not (find "" (pathname-directory dir)
				 :test #'equal)))
	      dir)
	    :when :around
	    :name fad--pathname-as-directory-safety)

Oh, and a Merry Solstice to all, and to all a good night!

from cl-fad.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.