Mark H Weaver <m...@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’.