GNU bug report logs - #19742
'wrap-program' should really preserve argv[0]

Previous Next

Package: guix;

Reported by: ludo <at> gnu.org (Ludovic Courtès)

Date: Sun, 1 Feb 2015 23:32:02 UTC

Severity: normal

Done: Andreas Enge <andreas <at> enge.fr>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: ludo <at> gnu.org (Ludovic Courtès)
To: Andreas Enge <andreas <at> enge.fr>
Cc: 19742 <at> debbugs.gnu.org
Subject: bug#19742: 'wrap-program' should really preserve argv[0]
Date: Mon, 23 Feb 2015 20:42:58 +0100
Andreas Enge <andreas <at> enge.fr> skribis:

> * guix/build/utils.scm (wrap-program): Create scripts that use $0 (which is
>     usually just the base name) instead of the absolute path to the original
>     program. Alternative implementation of 2ed11b3.
>
> Co-authored-by: Ludovic Courtès <ludo <at> gnu.org>
>
> Closes <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19742>.
> ---
>  guix/build/utils.scm | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/guix/build/utils.scm b/guix/build/utils.scm
> index c7fdd1d..a3446cb 100644
> --- a/guix/build/utils.scm
> +++ b/guix/build/utils.scm
> @@ -816,7 +816,7 @@ contents:
>    #!location/of/bin/bash
>    export PATH=\"/gnu/.../bar/bin\"
>    export CERT_PATH=\"$CERT_PATH${CERT_PATH:+:}/gnu/.../baz/certs:/qux/certs\"
> -  exec -a location/of/foo location/of/.foo-real \"$@\"
> +  exec -a $0 location/of/.foo-real \"$@\"
>  
>  This is useful for scripts that expect particular programs to be in $PATH, for
>  programs that expect particular shared libraries to be in $LD_LIBRARY_PATH, or
> @@ -870,11 +870,10 @@ the previous wrapper."
>      (with-output-to-file prog-tmp
>        (lambda ()
>          (format #t
> -                "#!~a~%~a~%exec -a \"~a\" \"~a\" \"$@\"~%"
> +                "#!~a~%~a~%exec -a \"$0\" \"~a\" \"$@\"~%"
>                  (which "bash")
>                  (string-join (map export-variable vars)
>                               "\n")
> -                (canonicalize-path prog)

Indeed, it’s better this way.  Please apply to ‘core-updates’ if not
already done.

Thanks,
Ludo’.




This bug report was last modified 10 years and 149 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.