bournish: 'ls' lists directory contents.
Suggested by Ricardo Wurmus. * guix/build/bournish.scm (ls-command-implementation): When FILE is a directory, list its contents rather than FILE itself.master
parent
0e40b75506
commit
c7d1b061f5
|
@ -1,5 +1,5 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
|
||||
;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
|
||||
;;;
|
||||
|
@ -81,15 +81,29 @@ characters."
|
|||
(()
|
||||
(display-tabulated (scandir ".")))
|
||||
(files
|
||||
(let ((files (filter (lambda (file)
|
||||
(let ((files (append-map (lambda (file)
|
||||
(catch 'system-error
|
||||
(lambda ()
|
||||
(lstat file))
|
||||
(match (stat:type (lstat file))
|
||||
('directory
|
||||
;; Like GNU ls, list the contents of
|
||||
;; FILE rather than FILE itself.
|
||||
(match (scandir file
|
||||
(match-lambda
|
||||
((or "." "..") #f)
|
||||
(_ #t)))
|
||||
(#f
|
||||
(list file))
|
||||
((files ...)
|
||||
(map (cut string-append file "/" <>)
|
||||
files))))
|
||||
(_
|
||||
(list file))))
|
||||
(lambda args
|
||||
(let ((errno (system-error-errno args)))
|
||||
(format (current-error-port) "~a: ~a~%"
|
||||
file (strerror errno))
|
||||
#f))))
|
||||
'()))))
|
||||
files)))
|
||||
(display-tabulated files)))))
|
||||
|
||||
|
|
Reference in New Issue