From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: bug#36772: feature request: checked variant of "substitute*" Date: Tue, 23 Jul 2019 15:35:19 +0200 Message-ID: <87zhl4c1rc.fsf@elephly.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:60620) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpuxZ-0006wW-Q7 for bug-guix@gnu.org; Tue, 23 Jul 2019 09:36:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpuxW-0001AL-8J for bug-guix@gnu.org; Tue, 23 Jul 2019 09:36:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53568) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hpuxW-0001AB-5Q for bug-guix@gnu.org; Tue, 23 Jul 2019 09:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hpuxV-0006yE-U0 for bug-guix@gnu.org; Tue, 23 Jul 2019 09:36:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: 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: Robert Vollmert Cc: 36772@debbugs.gnu.org Hi Robert, > I think it would be great to have the following variant of substitute*: > > (substitute*-once filename (pattern vars) body) > > 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. I agree that the effect of substitute* should be checked. I think substitute* should fail when one of its clauses failed to match anything. 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 th= at and it=E2=80=99s a simple extension to failing on zero matches. What do you think? -- Ricardo