From fdf1d824ae1b021d5083c812b3ff74fdade8d4bd Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 23 Nov 2024 22:29:32 -0500 Subject: [PATCH 1/3] Use relocatable shebang with space-in-path robustness --- cpython-unix/build-cpython.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpython-unix/build-cpython.sh b/cpython-unix/build-cpython.sh index 49c89d26..d5583431 100755 --- a/cpython-unix/build-cpython.sh +++ b/cpython-unix/build-cpython.sh @@ -858,7 +858,8 @@ def fix_shebang(full): lines.extend([ b"#!/bin/sh\n", - b'"exec" "\$(dirname \$0)/python${PYTHON_MAJMIN_VERSION}${PYTHON_BINARY_SUFFIX}" "\$0" "\$@"\n', + b"'''exec' \"$(dirname -- \"$(realpath -- \"$0\")\")\"/'python${PYTHON_MAJMIN_VERSION}${PYTHON_BINARY_SUFFIX}' \"$0\" \"$@\"\n", + b"' '''\n", ]) lines.extend(fh) From e2458be001f5c9b687c7d2ec0a05a40585cb8878 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 24 Nov 2024 20:15:34 -0500 Subject: [PATCH 2/3] Re-escape --- cpython-unix/build-cpython.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpython-unix/build-cpython.sh b/cpython-unix/build-cpython.sh index d5583431..c0c4ff25 100755 --- a/cpython-unix/build-cpython.sh +++ b/cpython-unix/build-cpython.sh @@ -858,7 +858,7 @@ def fix_shebang(full): lines.extend([ b"#!/bin/sh\n", - b"'''exec' \"$(dirname -- \"$(realpath -- \"$0\")\")\"/'python${PYTHON_MAJMIN_VERSION}${PYTHON_BINARY_SUFFIX}' \"$0\" \"$@\"\n", + b"'''exec' \"$(dirname -- \\\"$(realpath -- \\\"$0\\\")\\\")\"/'python${PYTHON_MAJMIN_VERSION}${PYTHON_BINARY_SUFFIX}' \"$0\" \"$@\"\n", b"' '''\n", ]) From edbb772cd063c3290d52d9538e90fb163fcb66b2 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 1 Dec 2024 22:02:13 -0500 Subject: [PATCH 3/3] Try again --- cpython-unix/build-cpython.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpython-unix/build-cpython.sh b/cpython-unix/build-cpython.sh index c0c4ff25..4016aaf6 100755 --- a/cpython-unix/build-cpython.sh +++ b/cpython-unix/build-cpython.sh @@ -858,7 +858,7 @@ def fix_shebang(full): lines.extend([ b"#!/bin/sh\n", - b"'''exec' \"$(dirname -- \\\"$(realpath -- \\\"$0\\\")\\\")\"/'python${PYTHON_MAJMIN_VERSION}${PYTHON_BINARY_SUFFIX}' \"$0\" \"$@\"\n", + b"'''exec' \"\$(dirname -- \"\$(realpath -- \"\$0\")\")/python${PYTHON_MAJMIN_VERSION}${PYTHON_BINARY_SUFFIX}\" \"\$0\" \"\$@\"\n", b"' '''\n", ])