From 4e0a4c107e4a2ee708e6e7a9f3edf189fe858f14 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 11 Mar 2022 15:27:00 -0700 Subject: replace ESCAPE-SH-TOKEN and ESCAPE-SH-COMMAND with new SH-ESCAPE Signed-off-by: Sean Whitton --- src/util.lisp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/util.lisp') 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." -- cgit v1.2.3