all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: bug-guix@gnu.org
Subject: Re: [PATCH] Improve shell script headers and pre-inst-env handling
Date: Wed, 13 Feb 2013 21:57:29 +0100	[thread overview]
Message-ID: <87ehgklyo6.fsf@gnu.org> (raw)
In-Reply-To: <87k3qcilmu.fsf@tines.lan> (Mark H. Weaver's message of "Wed, 13 Feb 2013 04:55:05 -0500")

Mark H Weaver <mhw@netris.org> skribis:

> So I've been working on a patch to fix the ./pre-inst-env problem using
> portable shell code instead of Guile code, as you suggested, and this is
> the kind of code I'm coming up with:

The first snippet looks good to me.

> but the more I look at this ugly, buggy code; and the more I fret
> about the inherent bugs having to do with poor handling of shell
> meta-characters and colons in file names; and the more I read of the
> "Portable Shell Programming" chapter of the autoconf manual, the less
> I understand why you feel so strongly about using this awful language
> instead of the Guile code I wrote.  To save a few lines?

I think either we mix shell and Scheme (which we more or less have to do
because Guile is largely unusable as a shebang for several reasons), in
which case the shell snippet should be as small as possible, or we do
Scheme-only (which I thought was impossible, but I could be wrong.)

So:

> Please take a look at my proposed code one more time with fresh eyes:

[...]

> startup="
> (let ()
>   (define-syntax-rule (push! elt v) (set! v (cons elt v)))
>   (define (main interpreter module-dir script-file . args)
>     (unless (getenv \"GUIX_UNINSTALLED\")
>       (push! module-dir %load-path)
>       (push! module-dir %load-compiled-path))
>     (load script-file)
>     (let ((proc (module-ref (resolve-interface '($script))
>                             '$script)))
>       (apply proc args)))
>   (apply main (command-line)))

Would this work if we used “#!@GUILE@ -ds” and do that from there?

> * The boilerplate code is identical in all scripts except on line 4
>   (script=guix-build).

Note that I think we’ll most likely have a single ‘guix’ script in the
near future, so that ‘guix-pull’ can actually update everything: Guix,
commands, and distro.

>> (BTW, rather than $GUIX_UNINSTALLED, it just occurred to me that
>> $GUIX_LOAD_PATH would do just as well while being more generic and
>> easier to implement/use.)
>
> I thought about this too, but it seems to me that it wouldn't work
> properly for "./pre-inst-env guile".  Or am I missing something?

Something like:

--8<---------------cut here---------------start------------->8---
GUILE_LOAD_COMPILED_PATH="${GUIX_LOAD_PATH}${GUIX_LOAD_PATH:+:}@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH"
export GUILE_LOAD_COMPILED_PATH
GUILE_LOAD_PATH="${GUIX_LOAD_PATH}${GUIX_LOAD_PATH:+:}@guilemoduledir@:$GUILE_LOAD_PATH"
export GUILE_LOAD_PATH

main='(module-ref (resolve-interface '\''(guix-package)) '\'guix-package')'
exec ${GUILE-@GUILE@} -l "$0" ...
--8<---------------cut here---------------end--------------->8---

Thoughts?  :-)

Ludo’.

  reply	other threads:[~2013-02-13 20:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-12  1:45 [PATCH] Improve shell script headers and pre-inst-env handling Mark H Weaver
2013-02-12  2:24 ` Mark H Weaver
2013-02-12  4:36   ` Mark H Weaver
2013-02-12 15:53   ` Ludovic Courtès
2013-02-12 15:56 ` Ludovic Courtès
2013-02-12 18:44   ` Mark H Weaver
2013-02-12 21:48     ` Ludovic Courtès
2013-02-12 22:44       ` Mark H Weaver
2013-02-13 14:42         ` Ludovic Courtès
2013-02-13  9:55       ` Mark H Weaver
2013-02-13 20:57         ` Ludovic Courtès [this message]
2013-02-14  8:28           ` Mark H Weaver
2013-02-14  9:44             ` [PATCH] Replace individual scripts with master 'guix' script Mark H Weaver
2013-02-14 13:41               ` Ludovic Courtès
2013-02-14 23:13                 ` Mark H Weaver
2013-02-16 20:57                   ` Ludovic Courtès
2013-02-17 14:59                   ` Ludovic Courtès

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=87ehgklyo6.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=bug-guix@gnu.org \
    --cc=mhw@netris.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.
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.