diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-06-25 15:12:14 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-06-27 13:26:21 -0700 |
commit | afe955cbd1dab48cf15a5a9b3f033d47d87720f4 (patch) | |
tree | d2ff5bbddf94471e8f29015d90fbf71d22e84702 /src/util.lisp | |
parent | 911bb7fc7597a83d1453ae083e33d7eaa8640f6b (diff) | |
download | consfigurator-afe955cbd1dab48cf15a5a9b3f033d47d87720f4.tar.gz |
convert some internal shell snippets to single lines
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/util.lisp')
-rw-r--r-- | src/util.lisp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.lisp b/src/util.lisp index c78005f..cd986d9 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -432,6 +432,21 @@ expansion as a starting point for your own DEFPACKAGE form for your consfig." ,@body ,result))))) +(defun sh-script-to-single-line (script) + "Attempt to convert a multiline POSIX sh script to a single line. + +The current implementation is naïve, and certainly unsuitable for converting +arbitrary scripts. Thus, this function is presently intended to be used only +on simple scripts embedded in source code, written with newlines for the sake +of maintainability. Converting those scripts to single lines before they are +executed improves Consfigurator's debug output, and also makes process names +visible to remote commands like ps(1) more readable." + (re:regex-replace-all + #?/\s+/ (re:regex-replace-all "(then|else|elif|fi|case|in|;;|do|done);" + (format nil "~{~A~^; ~}" (lines script)) + "\\1") + " ")) + ;;;; Progress & debug printing |