* [bug#62814] [PATCH] Clarify substitute* docstring with an additional example
@ 2023-04-13 11:44 Wicki Gabriel (wicg)
2023-05-11 12:38 ` bug#62814: " Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Wicki Gabriel (wicg) @ 2023-04-13 11:44 UTC (permalink / raw)
To: 62814
[-- Attachment #1.1: Type: text/plain, Size: 215 bytes --]
Hello
I've created this little patch after wondering how to match (and substitute*) against end-of-line. My patch is based on
982698c52fb388e278dc4cec4b124406f23f102a.
Thanks for review and merge.
gabber
[-- Attachment #1.2: Type: text/html, Size: 1696 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-guix-build-utils-Clarify-substitute-docstring-with-a.patch --]
[-- Type: text/x-patch; name="0001-guix-build-utils-Clarify-substitute-docstring-with-a.patch", Size: 1691 bytes --]
From 5ae3c5512e85189a47c859c6128adfd3bfc63159 Mon Sep 17 00:00:00 2001
From: Gabriel Wicki <gabriel@erlikon.ch>
Date: Thu, 13 Apr 2023 10:31:57 +0200
Subject: [PATCH] guix: build: utils: Clarify substitute* docstring with an
example.
* guix/build/utils.scm (substitute*): Add an example on how to match
end-of-line.
* doc/guix.texi (Build Utilities): Update the corresponding passage.
---
doc/guix.texi | 3 ++-
guix/build/utils.scm | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index acb6f0c2e1..71fa9f1dea 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10321,7 +10321,8 @@ Alternatively, @var{file} may be a list of file names, in which case
they are all subject to the substitutions.
Be careful about using @code{$} to match the end of a line; by itself it
-won't match the terminating newline of a line.
+won't match the terminating newline of a line, e.g. to match a whole
+line ending with a backslash, one needs a regex like @code{"(.*)\\\\\n$"}.
@end defmac
@subsection File Search
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index dd5a91f52f..6add9afc1b 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -957,7 +957,8 @@ (define-syntax substitute*
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."
+match the terminating newline of a line, e.g. to match a whole line ending
+with a backslash, one needs a regex like \"(.*)\\\\\n$\"."
((substitute* file ((regexp match-var ...) body ...) ...)
(let ()
(define (substitute-one-file file-name)
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#62814: [PATCH] Clarify substitute* docstring with an additional example
2023-04-13 11:44 [bug#62814] [PATCH] Clarify substitute* docstring with an additional example Wicki Gabriel (wicg)
@ 2023-05-11 12:38 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2023-05-11 12:38 UTC (permalink / raw)
To: Wicki Gabriel (wicg); +Cc: 62814-done
Hi,
"Wicki Gabriel (wicg)" <wicg@zhaw.ch> skribis:
> From 5ae3c5512e85189a47c859c6128adfd3bfc63159 Mon Sep 17 00:00:00 2001
> From: Gabriel Wicki <gabriel@erlikon.ch>
> Date: Thu, 13 Apr 2023 10:31:57 +0200
> Subject: [PATCH] guix: build: utils: Clarify substitute* docstring with an
> example.
>
> * guix/build/utils.scm (substitute*): Add an example on how to match
> end-of-line.
> * doc/guix.texi (Build Utilities): Update the corresponding passage.
[...]
> Be careful about using @code{$} to match the end of a line; by itself it
> -won't match the terminating newline of a line.
> +won't match the terminating newline of a line, e.g. to match a whole
> +line ending with a backslash, one needs a regex like @code{"(.*)\\\\\n$"}.
Applied with a minor tweak and without the (guix build utils) change,
which would entail a world rebuild.
Thanks!
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-11 12:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 11:44 [bug#62814] [PATCH] Clarify substitute* docstring with an additional example Wicki Gabriel (wicg)
2023-05-11 12:38 ` bug#62814: " Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).