unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: swedebugia <swedebugia@riseup.net>
Cc: guix-devel@gnu.org
Subject: Re: Help with substitute*
Date: Tue, 13 Nov 2018 22:07:22 -0500	[thread overview]
Message-ID: <874lckpda2.fsf@netris.org> (raw)
In-Reply-To: <f10d2cab-ac00-82a5-aacf-f7562026dacb@riseup.net> (swedebugia's message of "Tue, 13 Nov 2018 22:29:34 +0100")

Hi,

swedebugia <swedebugia@riseup.net> 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	other threads:[~2018-11-14  3:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-13 21:29 Help with substitute* swedebugia
2018-11-14  3:07 ` Mark H Weaver [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874lckpda2.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guix-devel@gnu.org \
    --cc=swedebugia@riseup.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).