diff mbox series

[b4] b4.sh: keep existing PYTHONPATH if set

Message ID 20230402-wrapper-keep-pythonpath-v1-1-e2bc5e556a67@codewreck.org (mailing list archive)
State Accepted
Headers show
Series [b4] b4.sh: keep existing PYTHONPATH if set | expand

Commit Message

Dominique Martinet April 2, 2023, 3:24 a.m. UTC
for setups depending on PYTHONPATH being set to provide dependencies
e.g. requests, b4.sh overriding of the variable is too strong.

Set current directory and patatt's first but keep PYTHONPATH if it was
not empty.

While we are here, remove useless use of env: the shell does the job
just fine if the variable is set before exec

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---
 b4.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


---
base-commit: 00303592f25693cb4eddf58fb51063afcff8dceb
change-id: 20230402-wrapper-keep-pythonpath-cbac5c0cc618

Best regards,

Comments

Konstantin Ryabitsev May 26, 2023, 6:11 p.m. UTC | #1
On Sun, 02 Apr 2023 12:24:49 +0900, Dominique Martinet wrote:
> for setups depending on PYTHONPATH being set to provide dependencies
> e.g. requests, b4.sh overriding of the variable is too strong.
> 
> Set current directory and patatt's first but keep PYTHONPATH if it was
> not empty.
> 
> While we are here, remove useless use of env: the shell does the job
> just fine if the variable is set before exec
> 
> [...]

Applied, thanks!

[1/1] b4.sh: keep existing PYTHONPATH if set
      commit: bf2bb043b60cd8907f144a2d646c799c882ec711

Best regards,
diff mbox series

Patch

diff --git a/b4.sh b/b4.sh
index 10d33b740d5e..bd7e587151f2 100755
--- a/b4.sh
+++ b/b4.sh
@@ -6,4 +6,5 @@ 
 REAL_SCRIPT=$(realpath -e ${BASH_SOURCE[0]})
 SCRIPT_TOP="${SCRIPT_TOP:-$(dirname ${REAL_SCRIPT})}"
 
-exec env PYTHONPATH="${SCRIPT_TOP}:${SCRIPT_TOP}/patatt" python3 "${SCRIPT_TOP}/b4/command.py" "${@}"
+PYTHONPATH="${SCRIPT_TOP}:${SCRIPT_TOP}/patatt${PYTHONPATH:+:$PYTHONPATH}" \
+	exec python3 "${SCRIPT_TOP}/b4/command.py" "${@}"