diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-03-11 15:27:00 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-03-11 16:40:08 -0700 |
commit | 4e0a4c107e4a2ee708e6e7a9f3edf189fe858f14 (patch) | |
tree | b8e51af43f895a98ebd943580c51c1da38151bdf /src/util.lisp | |
parent | f2ba47b7ef017a01a4b6c13982ff43a67cc6abd5 (diff) | |
download | consfigurator-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.lisp | 12 |
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." |