diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-02 11:09:07 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-02 11:09:26 -0700 |
commit | afa3aa3d185f0f8b8cdb41832e97a2b8212f2339 (patch) | |
tree | fac76a843172e3cbcaa7c9f5deec7de54aaac4e6 | |
parent | 73c7683481de663df47a1422b7d0f012dbecfd8f (diff) | |
download | consfigurator-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>
-rw-r--r-- | src/package.lisp | 6 | ||||
-rw-r--r-- | src/util.lisp | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/package.lisp b/src/package.lisp index 091a84a..202d92a 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -9,8 +9,6 @@ #:string-suffix-p #:split-string #:last-char - #:escape-sh-command - #:escape-sh-token #:run-program #:read-file-string #:copy-stream-to-stream @@ -36,8 +34,6 @@ #:string-suffix-p #:split-string #:last-char - #:escape-sh-command - #:escape-sh-token #:run-program #:read-file-string #:copy-stream-to-stream @@ -72,6 +68,8 @@ #:define-print-object-for-structlike #:chroot-pathname #:in-chroot-pathname + #:escape-sh-token + #:escape-sh-command #:*consfigurator-debug-level* #:with-indented-inform 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 |