[Libguestfs] [libnbd PATCH 03/20] nbdsh: Check for python-exec2c installations

Martin Kletzander
Tue, 08 Jun 2021 07:53:44 -0000

Platforms that utilise python-exec [0] wrapper scripts (mainly Gentoo) utilise
basenames of python scripts and executables to decide which python
implementation to use for running that particular command.  That makes the nbdsh
"hack" in sh/nbdsh.in not work, even if 'exec -a' is supported
by sh.

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 sh/nbdsh.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sh/nbdsh.in b/sh/nbdsh.in
index d10f0c1b6b26..333c2d5f8b96 100644
--- a/sh/nbdsh.in
+++ b/sh/nbdsh.in
@@ -19,7 +19,8 @@

 # Test if /bin/sh supports exec -a option (only supported in bash 4.2
 # and above, and not part of POSIX).
-if /bin/sh -c 'exec -a test true' 2>/dev/null; then
+if /bin/sh -c 'exec -a test true' 2>/dev/null && \
+        test $(readlink $(which @PYTHON@)) != python-exec2c; then
     exec -a nbdsh @PYTHON@ -mnbd "$@"
 else
     exec          @PYTHON@ -mnbd "$@"
--
2.31.1