Raymond Toy pushed to branch issue-266-b-tilde-pathname-support at cmucl / cmucl
Commits: 59d58964 by Raymond Toy at 2023-12-06T13:59:14-08:00 Simplify code.
`user-homedir-namestring` did too much unneeded stuff. And don't signal an error here.
Signal an error in `replace-tilde-user` if the user can't be found.
- - - - -
1 changed file:
- src/code/filesys.lisp
Changes:
===================================== src/code/filesys.lisp ===================================== @@ -303,14 +303,9 @@
(defun user-homedir-namestring (name) (cond ((zerop (length name)) - (let ((user (unix:unix-getpwuid (unix:unix-getuid)))) - (concatenate 'simple-base-string - (unix:user-info-dir user)))) + (unix:user-info-dir (unix:unix-getpwuid (unix:unix-getuid)))) (t - (let ((path (system:get-user-homedir-namestring name))) - (unless path - (error "Unknown user: ~S" name)) - path)))) + (system:get-user-homedir-namestring name))))
(defun replace-tilde-user (str start end) ;; Quick exit if STR doesn't start with ~ or we have an empty string. @@ -326,6 +321,8 @@ (values str start end))) (let* ((user-name (subseq str (1+ start) end-user)) (homedir (user-homedir-namestring user-name))) + (unless homedir + (error "Unknown user ~S in namestring ~S" user-name (subseq str start end))) ;; Replace the ~user part with the home directory, adjusting END ;; because of the replacement. (values (concatenate 'simple-base-string
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/59d589645f9fbdc81dd46237...