guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with substitute*


From: Mark H Weaver
Subject: Re: Help with substitute*
Date: Tue, 13 Nov 2018 22:07:22 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hi,

swedebugia <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]