From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Vollmert Subject: bug#36772: feature request: checked variant of "substitute*" Date: Tue, 23 Jul 2019 15:41:58 +0200 Message-ID: <15DD757F-8CCE-4092-925C-0B76824B5E47@vllmrt.net> References: <87zhl4c1rc.fsf@elephly.net> Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:33735) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpv4J-0001JS-MZ for bug-guix@gnu.org; Tue, 23 Jul 2019 09:43:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpv4I-000446-Mg for bug-guix@gnu.org; Tue, 23 Jul 2019 09:43:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53572) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hpv4I-000440-JO for bug-guix@gnu.org; Tue, 23 Jul 2019 09:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hpv4I-00078s-GA for bug-guix@gnu.org; Tue, 23 Jul 2019 09:43:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87zhl4c1rc.fsf@elephly.net> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ricardo Wurmus Cc: 36772@debbugs.gnu.org > On 23. Jul 2019, at 15:35, Ricardo Wurmus wrote: >=20 >=20 > Hi Robert, >=20 >> I think it would be great to have the following variant of = substitute*: >>=20 >> (substitute*-once filename (pattern vars) body) >>=20 >> which acts like the usual substitute-*, except it also asserts that = the >> substitution applies to exactly one line in the file, causing a build >> failure otherwise. >=20 > I agree that the effect of substitute* should be checked. I think > substitute* should fail when one of its clauses failed to match > anything. >=20 > Each clause could also accept an optional argument to make them only > match one location. We wouldn=E2=80=99t have to duplicate the macro = for that > and it=E2=80=99s a simple extension to failing on zero matches. >=20 > What do you think? That sounds like a good improvement, too. I think the important part is ensuring the substitution matches at all, maybe we could leave out the =E2=80=9Cat most once=E2=80=9D part. (I doubt it would be used a lot if = it=E2=80=99s not the default.) Cheers Robert