unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Mortimer Cladwell <mbcladwell@gmail.com>
To: help-guix <help-guix@gnu.org>
Subject: Help needed with substitute* command
Date: Thu, 6 Jan 2022 07:53:17 -0500	[thread overview]
Message-ID: <CAOcxjM5hvMypudEOzUL8T+468HupS2wPW=KUthv_Oyi3wb9TDg@mail.gmail.com> (raw)

Hi,
I do not understand the second substitute* example in the Guix Manual.
I have the executable mysubs.scm:

--mysubs.scm---------------------------------------------------------
(add-to-load-path
"/gnu/store/rjzj1z89jqcb60nhg5gknkibcl84b3jb-guix-29745d23b-modules/share/guile/site/3.0")
(add-to-load-path ".")

(use-modules
    (guix build utils)
    (ice-9 rdelim)
    (ice-9 popen)
    (ice-9 regex) ;;list-matches
    (ice-9 pretty-print))

(define (main args)
  (begin
    (substitute* "./input.txt"
(("hello")
 "good morning\n")
(("foo([a-z]+)bar(.*)$" all letters end)
 (string-append "baz" letters end))))
  (pretty-print "done"))

  ---------end------------------------------------------------------------

  I run this on 2 different inputs representing the two examples in the
manual:


  ---input.txt(1)------
  hello

  ---------------------

  result: good morning


  ---input.txt(2)-------
  foo(abc)bar(def)

  -------------------

  result:  foo(abc)bar(def)

  Why no substitution with the second example?
  Is the letters/letter in the manual a typo?  If I use letter I get
"...unbound variable..."

  Thanks
  Mortimer

             reply	other threads:[~2022-01-06 12:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 12:53 Mortimer Cladwell [this message]
2022-01-06 13:50 ` Help needed with substitute* command Tobias Geerinckx-Rice
2022-01-06 14:53   ` Mortimer Cladwell

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='CAOcxjM5hvMypudEOzUL8T+468HupS2wPW=KUthv_Oyi3wb9TDg@mail.gmail.com' \
    --to=mbcladwell@gmail.com \
    --cc=help-guix@gnu.org \
    /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.
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).