From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark H Weaver Subject: Re: Help with substitute* Date: Tue, 13 Nov 2018 22:07:22 -0500 Message-ID: <874lckpda2.fsf@netris.org> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMlXB-0008UG-W4 for guix-devel@gnu.org; Tue, 13 Nov 2018 22:08:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMlX8-0002UN-1F for guix-devel@gnu.org; Tue, 13 Nov 2018 22:08:05 -0500 Received: from world.peace.net ([64.112.178.59]:56256) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMlX7-0002UF-UZ for guix-devel@gnu.org; Tue, 13 Nov 2018 22:08:01 -0500 In-Reply-To: (swedebugia's message of "Tue, 13 Nov 2018 22:29:34 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: swedebugia Cc: guix-devel@gnu.org Hi, swedebugia writes: > I refactored my substitute* into that below. > Now it runs without substitute anything :S Actually, the first two substitutions worked, but not the latter two. See below. > + (substitute* "setup.py" > + (("iptables_exe = ''") > + (string-append "iptables_exe = '" iptables "/sbin/iptables'")) > + (("iptables_dir = ''") > + (string-append "iptables_dir = '" iptables "/sbin/'")) > + (("real_confdir = os.path.join('/etc')") > + (string-append "real_confdir = '" out "/etc/'")) > + (("real_statedir = os.path.join('/lib', 'ufw')") > + (string-append "real_statedir = '" out "/lib/ufw'")))) In the latter two substitutions above, the parentheses '(' and ')' are special characters in regular expression syntax. In order to avoid their special meaning, and match actual parentheses, you need to escape them by preceding each with a backslash. However, backslash is also a special character in Scheme string literal syntax, so you need to put two backslashes to get a single backslash in the actual string. So, it should look like this: --8<---------------cut here---------------start------------->8--- (substitute* "setup.py" (("iptables_exe = ''") (string-append "iptables_exe = '" iptables "/sbin/iptables'")) (("iptables_dir = ''") (string-append "iptables_dir = '" iptables "/sbin/'")) (("real_confdir = os.path.join\\('/etc'\\)") (string-append "real_confdir = '" out "/etc/'")) (("real_statedir = os.path.join\\('/lib', 'ufw'\\)") (string-append "real_statedir = '" out "/lib/ufw'")))) --8<---------------cut here---------------end--------------->8--- With this change, the package builds, although I haven't done any further testing. Mark