From df94888eca214c496b5cdf57795e03b96866c3af Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 22 Sep 2024 15:06:18 +0900 Subject: [PATCH] utils: Set $0 to basename of command in `wrap-program'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/build/utils.scm (wrap-program): Set the value of the -a option of `exec' in the wrapper to ${0##*/} instead of $0, to use its base name instead of the complete file name. Fixes: https://issues.guix.gnu.org/73405 Change-Id: Iec5984d4d934c8df88a90ff653947f7d07413ae4 Signed-off-by: Ludovic Courtès --- guix/build/utils.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 94714bf3973cb292e1769adc659920a5aad7ae39..7003d8262fcc3509377f2e4c66d168e5818d6b19 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -1355,7 +1355,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 $0 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 @@ -1432,7 +1432,7 @@ with definitions for VARS. If it is not, SH will be used as interpreter." (call-with-output-file prog-tmp (lambda (port) (format port - "#!~a~%~a~%exec -a \"$0\" \"~a\" \"$@\"~%" + "#!~a~%~a~%exec -a \"${0##*/}\" \"~a\" \"$@\"~%" sh (string-join (map export-variable vars/filtered) "\n") (canonicalize-path wrapped-file))))