diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-02-24 10:47:29 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-02-24 10:47:29 -0700 |
commit | 9490953e268b89f4219ed9f724e71cc6e4526665 (patch) | |
tree | b01f1e4d6ae04e330b923aff02b2ba0f81c2f0a2 /src/property/file.lisp | |
parent | a8a666f045ab7a5966d11cb2eac12ef099f23960 (diff) | |
download | consfigurator-9490953e268b89f4219ed9f724e71cc6e4526665.tar.gz |
add FILE:REGEX-REPLACE-LINES
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/file.lisp')
-rw-r--r-- | src/property/file.lisp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/property/file.lisp b/src/property/file.lisp index c3eaab5..ac997d3 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -42,3 +42,14 @@ (require-data (get-hostname) destination)) (:apply (data-uploaded (get-hostname) destination destination))) + +(defprop regex-replace-lines :posix (regex replace file) + "Like s/REGEX/REPLACE/ on the lines of FILE. +Uses CL-PPCRE:REGEX-REPLACE, which see for the syntax of REPLACE." + (:apply + (writefile + file + (unlines + (mapcar (lambda (line) + (re:regex-replace regex line replace)) + (lines (readfile file))))))) |