Search code examples
common-lispecl

Why does (probe-file #P"/") return nil?


This seems like it could be a bug in ECL's implementation -- or due to some detail in the standard:

    > (probe-file #P"/usr")

    #P"/usr/"
    > (probe-file #P"/usr/")

    #P"/usr/"
    > (probe-file #P"/")

    NIL
    > (probe-file #P"//")

    NIL

One more case:

    > (probe-file #P"/.")

    #P"/"

Update, FWIW, SBCL does what I expect:

    * (probe-file #P"/")

    #P"/"

Solution

  • Here is a commit message from the fix I'm testing right now (hope this answers the question – it was a bug indeed):

    unixfsys: remove coerce_to_posix_filename

    This was a workaround around bugs in cygwin and mingw (which are already fixed), when the directory name ended with '/'. This fix introduced extra bug with probe-file called on the root directory (it returned nil on all platforms).

    Original comment:

    This converts a pathname designator into a namestring, with the particularity that directories do not end with a slash '/', because this is not supported on all POSIX platforms (most notably Windows).

    Bug reference:

    https://sourceforge.net/p/mingw-w64/patches/34/

    Fixes #351.