diff --git a/scheme/complete-util.scm b/scheme/complete-util.scm index b2d3305..e35894e 100644 --- a/scheme/complete-util.scm +++ b/scheme/complete-util.scm @@ -40,7 +40,8 @@ (define (complete-with-filesystem-objects filter partial-name) (debug-message "complete-with-filesystem-objects " filter " " partial-name) - (if (file-exists-and-is-directory? partial-name) + (if (and (file-name-directory? partial-name) + (file-exists-and-is-directory? partial-name)) (files-in-dir filter partial-name) (filter-map filter (complete-path partial-name)))) @@ -73,10 +74,18 @@ (debug-message "find-completions-for-arg " cmd "," to-complete) (let ((prefix (to-complete-prefix to-complete))) (complete-with-filesystem-objects - (if prefix - (lambda (file) - (and (string-prefix? prefix file) file)) - (lambda (file) file)) + (lambda (file) + (call-with-current-continuation + (lambda (esc) + (with-handler + (lambda (c more) + (if (error? c) + (esc #f) + (more))) + (lambda () + (if (file-directory? file) + (file-name-as-directory file) + file)))))) (or (to-complete-prefix to-complete) (cwd))))) ;; #### no special treatment yet diff --git a/scheme/nuit-packages.scm b/scheme/nuit-packages.scm index 63b8904..78dcc0e 100644 --- a/scheme/nuit-packages.scm +++ b/scheme/nuit-packages.scm @@ -485,6 +485,8 @@ (subset scsh (file-name-directory glob with-cwd cwd file-name-extension + file-name-as-directory + file-name-directory? absolute-file-name expand-file-name file-exists? file-directory? file-executable? directory-files getenv))