unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Konrad Hinsen <konrad.hinsen@fastmail.net>
Cc: 41253@debbugs.gnu.org
Subject: [bug#41253] [PATCH v4] guix repl: Add script execution.
Date: Fri, 12 Jun 2020 17:58:37 +0200	[thread overview]
Message-ID: <87mu585l8y.fsf@gnu.org> (raw)
In-Reply-To: <m1a71gkbzx.fsf@khs-macbook.home> (Konrad Hinsen's message of "Sat, 06 Jun 2020 07:18:58 +0200")

Hi, and sorry for the delay!

Konrad Hinsen <konrad.hinsen@fastmail.net> skribis:

> * guix/scripts/repl.scm: Add filename options for script execution.
> * doc/guix.texi (Invoking guix repl): Document it.
> * tests/guix-repl.sh: Test it.
> * Makefile.am: (SH_TESTS): Add it.

I have some comments regarding style and how to deal with multiple
scripts, but I think we’re pretty much there.

> +The general syntax is:
> +
> +@example
> +guix repl @var{options} @var{file} @var{args}

Should be: [@var{file} @var{args}@dots{}]
The square brackets show it’s optional.

> +When a @var{file} argument is provided, @var{file} is
> +executed as a Guile scripts:

“When one or more @var{file} argument is provided, each @var{file} is
executed as a Guile program:”

> +  (define script (reverse
> +                  (map cdr
> +                       (filter (lambda (opt)
> +                                 (eq? (car opt) 'script))
> +                               opts))))

To avoid car/cdr (info "(guix) Data Types and Pattern Matching"), I
suggest something along these lines:

  (define scripts  ;plural, no?
    (reverse
     (filter-map (match-lambda
                   (('script . script) script)
                   (_ #f))
                 opts)))

> +  (define script-file
> +    (let ((file (car script))
> +          (directory (getcwd)))
> +      (canonicalize-path
> +       (cond ((string-prefix? "/" file) file)
> +             (else (string-append directory "/" file))))))

I think we can just use file names as they arrive, without attempting to
canonicalize them or anything.

> +    (unless (null? script)
> +      ;; Run script
> +      (save-module-excursion
> +       (lambda ()
> +         (set-program-arguments (cons script-file (cdr script)))
> +         (set-user-module)
> +         (load script-file))))

=> (for-each load scripts)
    
> +cat > "$tmpfile"<<EOF
> +#!/usr/bin/env -S guix repl --

Rather:

  #!$(type -P env)

This will ensure it works even in Guix build environments.

Could you send an updated patch?

Thank you!

Ludo’.




  reply	other threads:[~2020-06-12 15:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14  9:18 [bug#41253] [PATCH] guix: add script execution to "guix repl" Konrad Hinsen
2020-05-14 16:25 ` [bug#41253] [PATCH v2] guix repl: Add script execution zimoun
2020-05-29 10:11   ` [bug#41253] [PATCH v3] " Konrad Hinsen
2020-06-04 15:06     ` Ludovic Courtès
2020-06-05  8:48       ` Konrad Hinsen
2020-06-05 10:18         ` Konrad Hinsen
2020-06-05 16:36         ` Ludovic Courtès
2020-06-06  5:22           ` Konrad Hinsen
2020-06-06  5:18     ` [bug#41253] [PATCH v4] " Konrad Hinsen
2020-06-12 15:58       ` Ludovic Courtès [this message]
2020-06-13 16:39         ` Konrad Hinsen
2020-06-13 19:44           ` Ludovic Courtès
2020-06-14  7:02             ` Konrad Hinsen
2020-06-13 16:34       ` [bug#41253] [PATCH v5] " Konrad Hinsen
2020-06-14  7:00         ` [bug#41253] [PATCH v6] " Konrad Hinsen
2020-06-14 20:50           ` bug#41253: " Ludovic Courtès
2020-05-14 16:31 ` [bug#41253] [PATCH] guix: add script execution to "guix repl" zimoun
2020-05-29 10:16   ` Konrad Hinsen
2020-05-29 13:53     ` zimoun
2020-05-29 17:21       ` Konrad Hinsen

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=87mu585l8y.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=41253@debbugs.gnu.org \
    --cc=konrad.hinsen@fastmail.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).