bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Improve shell script headers and pre-inst-env handling


From: Ludovic Courtès
Subject: Re: [PATCH] Improve shell script headers and pre-inst-env handling
Date: Tue, 12 Feb 2013 16:56:44 +0100
User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux)

Mark H Weaver <address@hidden> skribis:

> The second patch is the main subject of this email.  It reworks the
> shell script headers at the top of 'guix-package' and the other scripts
> to avoid modifying environment variables (which could propagate to
> unrelated subprocesses that use libguile), and to avoid prepending
> installed directories to the guile load paths in the case where
> 'pre-inst-env' is being used.
>
> My approach here might be controversial, given that the resulting code
> is a bit longer, so if you don't like it, no worries :)

[...]

> +script=guix-build
> +
>  prefix="@prefix@"
>  datarootdir="@datarootdir@"
>  
> -GUILE_LOAD_COMPILED_PATH="@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH"
> -export GUILE_LOAD_COMPILED_PATH
> -
> -main='(module-ref (resolve-interface '\''(guix-build)) '\'guix-build')'
> -exec address@hidden@} -L "@guilemoduledir@" -l "$0"    \
> -         -c "(apply $main (cdr (command-line)))" "$@"
> +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)))
> +"
> +exec "address@hidden@}" -c "$startup" "@guilemoduledir@" "$0" "$@"

Well, it’s a bit longer.  :-)

Honestly, I wouldn’t worry about the propagation of $GUILE_LOAD_PATH &
co. to subprocesses, because we know there’s none anyway.

What about a simple:

  if test "x$GUIX_UNINSTALLED" = x; then
  ...

?

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]