Generally this looks good, but why did you put the change in with-current-directory instead of in call-with-current-directory, since the former is just a thin wrapper around the latter?

They are both exported, so I think it would be better to put it there. That leaves us with the following (rather ugly) form:

(let ((dir (resolve-symlinks*
                     (get-pathname-defaults
                      (pathname-directory-pathname
                       (ensure-directory-pathname
                        dir)))))
       ...)
  ...)

It's redundant to call pathname-directory-pathname on ensure-directory-pathname, so we just need the latter.

I will push this after testing.

On 25 Jun 2019, at 0:26, Spenser Truex wrote:

Neil Lindquist <neillindquist5@gmail.com>
writes:

Hello,

I recently noticed that uiop's DIRECTORY-FILES does not ensure that
the path is always interpreted as a directory. On sbcl (and
presumably other implementations), if the path does not have a
trailing slash, the files in the parent directory are instead
returned. This does not appear to be the indented behavior, given
that SUBDIRECTORIES ensures that the path is a directory.

May as well also do that for uiop:with-current-directory. I've attached
a diff, and have a test case below

Test case:
(uiop:with-current-directory ("/home/user")
(run-program "ls" :output t))

Behaviour is simiar to DIRECTORY-FILES.
;=> Current: lists my /home dir
;=> With diff: lists my /home/user dir

~~~~~~~~~~ DIFF ~~~~~~~~~~~~~

498c498
< `(call-with-current-directory ,dir #'(lambda () ,@body))))
---

`(call-with-current-directory (ensure-directory-pathname ,dir) #'(lambda
() ,@body))))

Coleslaw has been using a similar version of the above for awhile.

A patch for this new behavior and current/proposed results are below.
## Patch ##
--- a/uiop/filesystem.lisp
+++ b/uiop/filesystem.lisp
@@ -209,7 +209,7 @@ Subdirectories should NOT be returned.
override the default at your own risk.
DIRECTORY-FILES tries NOT to resolve symlinks if the implementation
permits this,
but the behavior in presence of symlinks is not portable. Use IOlib
to handle such situations."
- (let ((dir (pathname directory)))
+ (let ((dir (ensure-directory-pathname directory))))
(when (logical-pathname-p dir)
;; Because of the filtering we do below,
;; logical pathnames have restrictions on wild patterns.

--
Spenser Truex
usenet@spensertruex.com
https://spensertruex.com/
San Francisco, USA