aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>2014-11-25 21:52:13 +0100
committerLudovic Courtès <ludo@gnu.org>2014-11-26 11:17:48 +0100
commit094b2efc3c672d60c2fbaca68ce632ba6ab54700 (patch)
tree473df9548f02dfa1041b8b29bd1e051e6896d7c8
parent97e11209032cb10a40c588c66ebe9f345a85f234 (diff)
downloadpatches-094b2efc3c672d60c2fbaca68ce632ba6ab54700.tar
patches-094b2efc3c672d60c2fbaca68ce632ba6ab54700.tar.gz
utils: Improve docstring of 'substitute*' & co.
* guix/build/utils.scm (substitute): Clarify first sentence of docstring and add warning to the docstring about using '$' to match an end of line. (substitute*): Add warning to the docstring about using '$' to match an end of line. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--guix/build/utils.scm14
1 files changed, 9 insertions, 5 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index c480dbf8a6..737976e8e4 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -413,10 +413,11 @@ PROC's result is returned."
(false-if-exception (delete-file template))))))
(define (substitute file pattern+procs)
- "PATTERN+PROCS is a list of regexp/two-argument procedure. For each line
-of FILE, and for each PATTERN that it matches, call the corresponding PROC
-as (PROC LINE MATCHES); PROC must return the line that will be written as a
-substitution of the original line."
+ "PATTERN+PROCS is a list of regexp/two-argument-procedure pairs. For each
+line of FILE, and for each PATTERN that it matches, call the corresponding
+PROC as (PROC LINE MATCHES); PROC must return the line that will be written as
+a substitution of the original line. Be careful about using '$' to match the
+end of a line; by itself it won't match the terminating newline of a line."
(let ((rx+proc (map (match-lambda
(((? regexp? pattern) . proc)
(cons pattern proc))
@@ -476,7 +477,10 @@ When one of the MATCH-VAR is `_', no variable is bound to the corresponding
match substring.
Alternatively, FILE may be a list of file names, in which case they are
-all subject to the substitutions."
+all subject to the substitutions.
+
+Be careful about using '$' to match the end of a line; by itself it won't
+match the terminating newline of a line."
((substitute* file ((regexp match-var ...) body ...) ...)
(let ()
(define (substitute-one-file file-name)