From: Ladislav Michl <oss-lists@triops.cz>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [PATCH 4/6] ptxdist: don't depend on bash being /bin/bash
Date: Tue, 13 Oct 2026 13:18:00 +0200 [thread overview]
Message-ID: <as4TaBMzNACVgoKD@lenoch> (raw)
In-Reply-To: <as4S9kELLgKY9wdR@lenoch>
From: Ladislav Michl <ladis@triops.cz>
Provide a helpful message instead of 'bad interpreter' and check
bash version.
Signed-off-by: Ladislav Michl <ladis@triops.cz>
---
bin/ptxdist | 24 +++++++++++++++++++++++-
bin/ptxdist-auto-version | 4 ++--
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/bin/ptxdist b/bin/ptxdist
index 7b20026bb..3c86aa225 100755
--- a/bin/ptxdist
+++ b/bin/ptxdist
@@ -1,4 +1,26 @@
-#!/bin/bash
+#!/bin/sh
+
+#
+# Everything up to the bash version check must be plain POSIX sh: PTXdist
+# may be started by any shell and re-executes itself with bash.
+#
+if [ -z "${BASH_VERSION}" ]; then
+ bash="$(command -v bash)" || {
+ echo "ptxdist: error: bash >= 4.2 is required, please install it" >&2
+ exit 1
+ }
+ exec "${bash}" "${0}" "${@}"
+fi
+
+case "${BASH_VERSION}" in
+[0-3].*|4.[01].*)
+ echo "ptxdist: error: bash >= 4.2 is required, found ${BASH_VERSION} as '${BASH}'" >&2
+ exit 1
+ ;;
+esac
+
+# e.g. when started as 'sh' with /bin/sh -> bash
+set +o posix
LANG=C
LC_ALL=POSIX
diff --git a/bin/ptxdist-auto-version b/bin/ptxdist-auto-version
index 2f6414ae0..92c50fc3d 100755
--- a/bin/ptxdist-auto-version
+++ b/bin/ptxdist-auto-version
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/bin/sh
#
-# bash implementation of realpath / readlink -f
+# shell implementation of realpath / readlink -f
# arg1 - filename
realpath()
{
--
2.47.3
next prev parent reply other threads:[~2026-10-13 11:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 11:16 [ptxdist] [PATCH 0/6] New BSP from template Ladislav Michl
2026-10-13 11:16 ` [ptxdist] [PATCH 1/6] scripts: add ptxdist_bootstrap.sh with out-of-tree build support Ladislav Michl
2026-10-13 11:17 ` [ptxdist] [PATCH 2/6] ptxdist: introduce PTXDIST_HOSTTOOLS_DIR Ladislav Michl
2026-10-13 11:17 ` [ptxdist] [PATCH 3/6] ptxdist: prepare host tools on demand Ladislav Michl
2026-10-13 11:18 ` Ladislav Michl [this message]
2026-10-13 11:18 ` [ptxdist] [PATCH 5/6] configure: use ptxdist_bootstrap.sh to check the host Ladislav Michl
2026-10-13 11:18 ` [ptxdist] [PATCH 6/6] ptxdist: let new project raise from template Ladislav Michl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=as4TaBMzNACVgoKD@lenoch \
--to=oss-lists@triops.cz \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox