diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-06-07 10:05:40 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-06-07 16:07:58 -0700 |
commit | 1f489eb1936921f1f029ca9543480490ca89ae67 (patch) | |
tree | 859627db4a06fe0d75b1a6a1178807ba9ce0d7a5 /src | |
parent | c687d10681cb4455e27dceec68aa5379305ec76c (diff) | |
download | consfigurator-1f489eb1936921f1f029ca9543480490ca89ae67.tar.gz |
ls(1) parse: set LC_ALL not just LOCALE, and split fields properly
Previously our code assumed fields were separated with exactly one space, but
sometimes there is padding.
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src')
-rw-r--r-- | src/connection.lisp | 2 | ||||
-rw-r--r-- | src/property.lisp | 2 | ||||
-rw-r--r-- | src/property/file.lisp | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/src/connection.lisp b/src/connection.lisp index 3f979d2..9f945a1 100644 --- a/src/connection.lisp +++ b/src/connection.lisp @@ -467,7 +467,7 @@ PATH may be any kind of file, including directories." (#\x order) (#\- 0))))) (and (remote-exists-p path) - (let* ((ls (split-string (run "ls" "-ld" path))) + (let* ((ls (words (run :env '(:LC_ALL "C") "ls" "-ld" path))) (lscar (car ls))) (values (+ (sum (subseq lscar 1 4) #o100) (sum (subseq lscar 4 7) #o10) diff --git a/src/property.lisp b/src/property.lisp index f5c9680..3561267 100644 --- a/src/property.lisp +++ b/src/property.lisp @@ -568,7 +568,7 @@ PATH already has the specified CONTENT and MODE." ;; this is a safe parse of ls(1) output given its POSIX specification (defun ls-cksum (file) (let ((ls (ignore-errors - (split-string (run :env '(:LOCALE "C") "ls" "-dlL" file)))) + (words (run :env '(:LC_ALL "C") "ls" "-dlL" file)))) (cksum (ignore-errors (cksum file)))) (when (and ls cksum) (list* (car ls) cksum (subseq ls 2 8))))) diff --git a/src/property/file.lisp b/src/property/file.lisp index a54d38c..70d2679 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -136,7 +136,7 @@ Uses CL-PPCRE:REGEX-REPLACE, which see for the syntax of REPLACE." ;; readlink(1) is not POSIX (defun remote-link-target (symlink) - (loop with s = (stripln (run :env '(:LOCALE "POSIX") "ls" "-ld" symlink)) + (loop with s = (stripln (run :env '(:LC_ALL "C") "ls" "-ld" symlink)) with found = 0 for i from 0 below (length s) when (char= (elt s i) #\Space) |