Menu

#724 DIRECTORY does not match filenames lacking extensions against type=:WILD

closed-fixed
pathname (1)
5
2018-01-11
2018-01-06
No

DIRECTORY appears not to match filenames lacking extensions against wild pathnames having :WILD for the type:

(progn
   (assert (nth-value 1 (ensure-directories-exist "/tmp/test/"))) ;fresh directory
   (close (open "/tmp/test/file" :direction :output))
   (close (open "/tmp/test/file.txt" :direction :output))
   (directory (make-pathname :name :wild :type :wild :version :wild
                             :defaults #P"/tmp/test/")))
(#P"/private/tmp/test/file.txt")

I expected to see an entry for /tmp/test/file as well, for two reasons:

  1. 19.2.2.2.2 says "If :WILD is the value of a pathname component, that component is
    considered to be a wildcard, which matches anything", and I interpret NIL to be one kind of anything.

  2. PATHNAME-MATCH-P does match the pathname with NIL for the type, and PATHNAME-MATCH-P "should be consistent with DIRECTORY".

(pathname-match-p "/tmp/test/file"
                                       (make-pathname :name :wild :type :wild :version :wild
                                                                       :defaults #P"/tmp/test/"))
T

Environment and compilation information:

$ uname -a
Darwin m5.localdomain 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
$ clisp
  i i i i i i i       ooooo    o        ooooooo   ooooo   ooooo
  I I I I I I I      8     8   8           8     8     o  8    8
  I  \ `+' /  I      8         8           8     8        8    8
   \  `-+-'  /       8         8           8      ooooo   8oooo
    `-__|__-'        8         8           8           8  8
        |            8     o   8           8     o     8  8
  ------+------       ooooo    8oooooo  ooo8ooo   ooooo   8

Welcome to GNU CLISP 2.49 (2010-07-07) <http://clisp.cons.org/>

Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2010

Type :h and hit Enter for context help.

[1]> (software-version)
"GNU C 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)"
[2]> (software-type)
"/usr/bin/clang -m64 -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8 -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -Wno-format-nonliteral -O -falign-functions=4 -DUNIX_BINARY_DISTRIB -DENABLE_UNICODE -DDYNAMIC_MODULES -DNO_GETTEXT -I.  -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8 -L/usr/local/opt/readline/lib -L/usr/local/lib  -lreadline -lncurses  -liconv -L/usr/local/lib -lsigsegv -R/usr/local/lib libgnu_cl.a -L/usr/X11/lib -R/usr/X11/lib
SAFETY=0 HEAPCODES STANDARD_HEAPCODES WIDE_HARD GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.10
libiconv 1.11
libreadline 6.2"
[3]> (machine-type)
"X86_64"
[4]> *features*
(:REGEXP :SYSCALLS :I18N :LOOP :COMPILER :CLOS :MOP :CLISP :ANSI-CL :COMMON-LISP
 :LISP=CL :INTERPRETER :SOCKETS :GENERIC-STREAMS :LOGICAL-PATHNAMES :SCREEN
 :UNICODE :BASE-CHAR=CHARACTER :WORD-SIZE=64 :UNIX :MACOS)
[5]> 
Bye.

Discussion

  • Sam Steingold

    Sam Steingold - 2018-01-10

    test case:

    ;; https://sourceforge.net/p/clisp/bugs/724/
    (let* ((wd (ensure-directories-exist "bug-724/" :verbose t))
           (f1 (open (merge-pathnames wd "file")
                     :direction :probe :if-does-not-exist :create))
           (f2 (open (merge-pathnames wd "file.txt")
                     :direction :probe :if-does-not-exist :create))
           (pat (make-pathname :name :wild :type :wild :version :wild :defaults wd))
           (*default-pathname-defaults* (ext:probe-pathname ".")))
      (unwind-protect
           (list (mapcar #'enough-namestring (directory pat))
                 (pathname-match-p f1 pat)
                 (pathname-match-p f2 pat))
        (delete-file f1)
        (delete-file f2)
        #+clisp (ext:delete-directory wd)
        #-clisp (delete-file wd)))
    (("bug-724/file.txt" "bug-724/file") T T)
    
     
  • Sam Steingold

    Sam Steingold - 2018-01-11
    • labels: --> pathname
    • status: open --> closed-fixed
    • assigned_to: Sam Steingold
     

Log in to post a comment.