From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] Improve shell script headers and pre-inst-env handling Date: Tue, 12 Feb 2013 16:56:44 +0100 Message-ID: <87fw11v83n.fsf@gnu.org> References: <87haliz4nt.fsf@tines.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:49446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5IE5-0001a8-GX for bug-guix@gnu.org; Tue, 12 Feb 2013 10:56:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U5IE2-0002DH-HW for bug-guix@gnu.org; Tue, 12 Feb 2013 10:56:56 -0500 Received: from [2a01:e0b:1:123:ca0a:a9ff:fe03:271e] (port=39195 helo=xanadu.aquilenet.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5IE2-0002Bd-Ai for bug-guix@gnu.org; Tue, 12 Feb 2013 10:56:54 -0500 In-Reply-To: <87haliz4nt.fsf@tines.lan> (Mark H. Weaver's message of "Mon, 11 Feb 2013 20:45:10 -0500") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Mark H Weaver Cc: bug-guix@gnu.org Mark H Weaver 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=3Dguix-build > + > prefix=3D"@prefix@" > datarootdir=3D"@datarootdir@" >=20=20 > -GUILE_LOAD_COMPILED_PATH=3D"@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH" > -export GUILE_LOAD_COMPILED_PATH > - > -main=3D'(module-ref (resolve-interface '\''(guix-build)) '\'guix-build')' > -exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ > - -c "(apply $main (cdr (command-line)))" "$@" > +startup=3D" > +(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 "${GUILE-@GUILE@}" -c "$startup" "@guilemoduledir@" "$0" "$@" Well, it=E2=80=99s a bit longer. :-) Honestly, I wouldn=E2=80=99t worry about the propagation of $GUILE_LOAD_PAT= H & co. to subprocesses, because we know there=E2=80=99s none anyway. What about a simple: if test "x$GUIX_UNINSTALLED" =3D x; then ... ? Ludo=E2=80=99.