diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-08-04 17:03:10 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-08-04 17:12:11 -0700 |
commit | 821658d0eb52f4ddf9d65d23bb4152668ff2cd48 (patch) | |
tree | 1e0209b9aaeac325b525027ad12917f407051800 /src | |
parent | 89d3cef1268ca78bd4d7f3a262ecc4ad7e134c46 (diff) | |
download | consfigurator-821658d0eb52f4ddf9d65d23bb4152668ff2cd48.tar.gz |
add FILE:CONTAINS-CONF-UNSPACED
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src')
-rw-r--r-- | src/package.lisp | 1 | ||||
-rw-r--r-- | src/property/file.lisp | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/package.lisp b/src/package.lisp index e6f0362..4b51b70 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -436,6 +436,7 @@ #:host-secret-uploaded #:data-cache-purged #:contains-conf-equals + #:contains-conf-unspaced #:contains-conf-space #:contains-conf-tab #:contains-conf-shell diff --git a/src/property/file.lisp b/src/property/file.lisp index 4c09f6e..5f0f480 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -426,6 +426,19 @@ uncommented and used to set the value, if it exists." :parse-kv #?/^([^\s=]+)\s?=\s?(.*)/ :new-kv (lambda (k v) #?"${k} = ${v}")))) +(defprop contains-conf-unspaced :posix (file &rest pairs) + "Where FILE is a config file in which keys and values are separated by \"=\", +without spaces, there are no sections, and PAIRS is a list of even length of +alternating keys and values, set each of these keys and values in FILE. + +If there are any other lines which set values for the same keys, they will be +commented out; the first commented or uncommented line for each key will be +uncommented and used to set the value, if it exists." + (:desc (format nil "~A has ~{~A=~A~^, ~}" file pairs)) + (:apply (simple-conf-update file pairs + :parse-kv #?/^([^\s=]+)=(.*)/ + :new-kv (lambda (k v) #?"${k}=${v}")))) + (defprop contains-conf-shell :posix (file &rest pairs) "Where FILE is a shell config file, like those in /etc/default, and PAIRS is a list of even length of alternating keys and values, set each of these keys and |