aboutsummaryrefslogtreecommitdiff
path: root/src/util.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-03-11 15:27:00 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-03-11 16:40:08 -0700
commit4e0a4c107e4a2ee708e6e7a9f3edf189fe858f14 (patch)
treeb8e51af43f895a98ebd943580c51c1da38151bdf /src/util.lisp
parentf2ba47b7ef017a01a4b6c13982ff43a67cc6abd5 (diff)
downloadconsfigurator-4e0a4c107e4a2ee708e6e7a9f3edf189fe858f14.tar.gz
replace ESCAPE-SH-TOKEN and ESCAPE-SH-COMMAND with new SH-ESCAPE
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/util.lisp')
-rw-r--r--src/util.lisp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/util.lisp b/src/util.lisp
index 3238b79..18c1d46 100644
--- a/src/util.lisp
+++ b/src/util.lisp
@@ -265,13 +265,11 @@ one-dimensional collections of values."
(ensure-pathname (enough-pathname pathname chroot)
:ensure-absolute t :defaults #P"/"))
-(defun escape-sh-token (token &optional s)
- "Like UIOP:ESCAPE-SH-TOKEN, but also escape the empty string."
- (if (string= token "") (format s "\"\"") (uiop:escape-sh-token token s)))
-
-(defun escape-sh-command (command &optional s)
- "Like UIOP:ESCAPE-SH-COMMAND, but also escape the empty string."
- (uiop:escape-command command s 'escape-sh-token))
+(defun sh-escape (token-or-cmd &optional s)
+ (cond ((listp token-or-cmd) (uiop:escape-command token-or-cmd s 'sh-escape))
+ ((pathnamep token-or-cmd) (sh-escape (unix-namestring token-or-cmd) s))
+ ((string= token-or-cmd "") (format s "\"\""))
+ (t (uiop:escape-sh-token token-or-cmd s))))
(defun parse-username-from-id (output)
"Where OUTPUT is the output of the id(1) command, extract the username."