aboutsummaryrefslogtreecommitdiff
path: root/src/util.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.lisp')
-rw-r--r--src/util.lisp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util.lisp b/src/util.lisp
index ab372ed..cbc21c2 100644
--- a/src/util.lisp
+++ b/src/util.lisp
@@ -195,6 +195,12 @@ one-dimensional collections of values."
"Like UIOP:ESCAPE-SH-COMMAND, but also escape the empty string."
(uiop:escape-command token s 'escape-sh-token))
+(defun parse-username-from-id (output)
+ "Where OUTPUT is the output of the id(1) command, extract the username."
+ (multiple-value-bind (match groups)
+ (re:scan-to-strings "^uid=[0-9]+\\(([^)]+)" output)
+ (and match (elt groups 0))))
+
;;;; Progress & debug printing