aboutsummaryrefslogtreecommitdiff
path: root/src/util.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-05-02 11:09:07 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-05-02 11:09:26 -0700
commitafa3aa3d185f0f8b8cdb41832e97a2b8212f2339 (patch)
treefac76a843172e3cbcaa7c9f5deec7de54aaac4e6 /src/util.lisp
parent73c7683481de663df47a1422b7d0f012dbecfd8f (diff)
downloadconsfigurator-afa3aa3d185f0f8b8cdb41832e97a2b8212f2339.tar.gz
ESCAPE-SH-{TOKEN,COMMAND}: also escape the empty string
This protects zero-length arguments to shell commands. Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/util.lisp')
-rw-r--r--src/util.lisp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util.lisp b/src/util.lisp
index d9a6e2c..ab372ed 100644
--- a/src/util.lisp
+++ b/src/util.lisp
@@ -187,6 +187,14 @@ 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 (token &optional s)
+ "Like UIOP:ESCAPE-SH-COMMAND, but also escape the empty string."
+ (uiop:escape-command token s 'escape-sh-token))
+
;;;; Progress & debug printing