all messages for Guix-related lists mirrored at yhetil.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, zimoun <zimon.toutoune@gmail.com>
Subject: [bug#41253] [PATCH v3] guix repl: Add script execution.
Date: Fri, 05 Jun 2020 18:36:21 +0200	[thread overview]
Message-ID: <87d06d1ncq.fsf@gnu.org> (raw)
In-Reply-To: <m1wo4lkidm.fsf@khs-macbook.home> (Konrad Hinsen's message of "Fri, 05 Jun 2020 10:48:53 +0200")

Hello Konrad,

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

>> It cannot be used as a shebang, can it?
>
> It can. And that might be worth documenting. Here's an example:
>
>   ===== File foo.scm =========================================
>   #!/usr/bin/env -S guix repl
>   !#
>   (use-modules (ice-9 format))
>
>   (format #t "foo called with arguments: ~s\n"(command-line))
>   ===== End of file foo.scm ==================================
>
>   hinsen@guix ~$ ~/foo.scm a b c
>   ;;; note: source file /home/hinsen/temp/foo.scm
>   ;;;       newer than compiled /home/hinsen/.cache/guile/ccache/3.0-LE-8-4.2/home/hinsen/temp/foo.scm.go
>   foo called with arguments: ("/home/hinsen/temp/foo.scm" "a" "b" "c")

Nice!

> The ugly part is that the script needs to be called with '–' as its
> first argument if any of the following arguments start with dashes:
>
>   hinsen@guix ~$ ~/foo.scm -- --help
>   ;;; note: source file /home/hinsen/temp/foo.scm
>   ;;;       newer than compiled /home/hinsen/.cache/guile/ccache/3.0-LE-8-4.2/home/hinsen/temp/foo.scm.go
>   foo called with arguments: ("/home/hinsen/temp/foo.scm" "--help")
>
> That could be fixed at the price of a command line interface for "guix
> repl" that deviates a bit from Guix conventions. For example,
> is there's a file name argument, pass all arguments following it to the
> script, eliminating the need for –.

Yes, that makes sense to me.

> I'll try that in a v4, and also take into account all your remaining
> remarks. Just one note on the examples:
>
>>> +@example
>>> +$ guix repl -- my-script.scm --input=foo.txt
>>> +@end example
>>
>> I’d remove “$” from the examples.
>
> There are many examples in guix.texi with $, and also many without. Plus
> some with # as the command line prompt.

Yeah, the manual is kinda inconsistent, and I’m self-inconsistent to
tell the truth.  :-)

I’ve come to the conclusion that snippets that contain only input should
be written without a prompt, for easier copy/pasting.

(I’ve seen Python documentation where JS magic allows people to toggle
prompt display, I find it nice.)

> A technical question: is there any way to suppress the error message
> about the source being newer than the cached version? This is really
> annoying when running scripts.
>
>>   hinsen@guix ~$ ~/foo.scm a b c
>>   ;;; note: source file /home/hinsen/temp/foo.scm
>>   ;;;       newer than compiled /home/hinsen/.cache/guile/ccache/3.0-LE-8-4.2/home/hinsen/temp/foo.scm.go
>>   foo called with arguments: ("/home/hinsen/temp/foo.scm" "a" "b" "c")

I guess ~/.cache/…/*.go exists because you first ran “guile foo.scm”,
no?  In that case, you can simply remove that .go file.

The ‘guix’ command turns off auto-compilation so ‘guix repl’ scripts
would always be interpreted, for better or worse.

Thanks,
Ludo’.




  parent reply	other threads:[~2020-06-05 16:37 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 [this message]
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
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

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

  git send-email \
    --in-reply-to=87d06d1ncq.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=41253@debbugs.gnu.org \
    --cc=konrad.hinsen@fastmail.net \
    --cc=zimon.toutoune@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.