Barry Margolin <barmar@alum.mit.edu> wrote:
+---------------
| Is there any way in which a wild pathname could
| conceivably be the truename of a specific file?
+---------------
Try this with your favorite shell & CL:
$ echo "harmless, really" >badnamesortof
$ echo "bad file, BAD!" >badname\*
$ ls -l badname*
-rw-r--r-- 1 rpw3 rpw3 15 Feb 24 02:30 badname*
-rw-r--r-- 1 rpw3 rpw3 17 Feb 24 02:36 badnamesortof
$ cmu
cmu> (pathname "badname*")
#p"badname*"
cmu> (describe *)
#p"badname*" is a structure of type PATHNAME.
HOST: #<COMMON-LISP::UNIX-HOST>.
DEVICE: NIL.
DIRECTORY: NIL.
NAME: #<COMMON-LISP::PATTERN "badname" :MULTI-CHAR-WILD>.
TYPE: NIL.
VERSION: :NEWEST.
cmu> (directory **)
(#p"/u/rpw3/badname\\*" #p"/u/rpw3/badnamesortof")
cmu> (directory (car *))
(#p"/u/rpw3/badname\\*")
cmu> (truename (car *))
#p"/u/rpw3/badname\\*"
cmu> (with-open-file (s *)
(loop for line = (read-line s nil nil)
while line do
(format t "~a~%" line)))
bad file, BAD!
NIL
cmu> (describe **)
#p"/u/rpw3/badname\\*" is a structure of type PATHNAME.
HOST: #<COMMON-LISP::UNIX-HOST>.
DEVICE: NIL.
DIRECTORY: (:ABSOLUTE "u" "rpw3").
NAME: "badname*".
TYPE: NIL.
VERSION: :NEWEST.
cmu>
Hmmmm... That's not actually a "wild pathname", is it?
Though note that the *printed* representations of both
the "real" wild pathname and the individual file were the
same, and if one were particularly sloppy in subsequent
manipulations one might get back to a wild pathname by
mistake, e.g.:
cmu> (pathname (pathname-name ***))
#p"badname*"
cmu> (describe *)
#p"badname*" is a structure of type PATHNAME.
HOST: #<COMMON-LISP::UNIX-HOST>.
DEVICE: NIL.
DIRECTORY: NIL.
NAME: #<COMMON-LISP::PATTERN "badname" :MULTI-CHAR-WILD>.
TYPE: NIL.
VERSION: :NEWEST.
cmu>
Oops.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607