summaryrefslogtreecommitdiff
path: root/include/init.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-09-26 00:09:46 +0100
committerLeah Rowe <leah@libreboot.org>2025-09-26 00:09:46 +0100
commite42cb4f4cd513f512397ff7a46b6174b39a9708e (patch)
treeab6ba25c737cfa17ed6bc6eb9e1c4f5419ff892b /include/init.sh
parentf5060232e16ab1c041f0108a5f65d8f96f79756d (diff)
xbmk: tidy up some if statements
this is an extension of the previous work to unroll most of the condensed code lines. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/init.sh')
-rw-r--r--include/init.sh17
1 files changed, 7 insertions, 10 deletions
diff --git a/include/init.sh b/include/init.sh
index 488b87f0..ed60bfc2 100644
--- a/include/init.sh
+++ b/include/init.sh
@@ -283,27 +283,22 @@ xbmk_set_pyver()
if ! pybin python3 1>/dev/null; then
python="python"
fi
-
if [ "$python" = "python3" ]; then
pyver="3"
fi
-
if ! pybin "$python" 1>/dev/null; then
pyver=""
fi
-
if [ -n "$pyver" ]; then
"`x_ pybin "$python"`" -c "$pyv" 1>/dev/null \
2>/dev/null || \
err "Can't detect Python version." "xbmk_set_pyver" "$@"
fi
-
if [ -n "$pyver" ]; then
pyver="$("$(pybin "$python")" -c "$pyv" | awk '{print $1}')"
pyver="${pyver#(}"
pyver="${pyver%,}"
fi
-
if [ "${pyver%%.*}" != "3" ]; then
err "Bad python version (must by 3.x)" "xbmk_set_pyver" "$@"
fi
@@ -331,7 +326,6 @@ pybin()
if ! command -v "$1" 1>/dev/null 2>/dev/null; then
venv=0
fi
-
if [ $venv -gt 0 ]; then
if ! "$1" -c "$py" 1>/dev/null 2>/dev/null; then
venv=0
@@ -354,11 +348,14 @@ pybin()
fi
fi
- # if python venv: fall back to common PATH directories for checking
+ # if python venv: fall back to common PATH directories for checking:
+
[ $venv -gt 0 ] && for pypath in "/usr/local/bin" "/usr/bin"; do
- [ -e "$pypath/$1" ] && [ ! -d "$pypath/$1" ] && \
- [ -x "$pypath/$1" ] && printf "%s/%s\n" "$pypath" "$1" && \
- return 0
+ if [ -e "$pypath/$1" ] && [ ! -d "$pypath/$1" ] && \
+ [ -x "$pypath/$1" ]; then
+ printf "%s/%s\n" "$pypath" "$1"
+ return 0
+ fi
done && return 1
# Defer to normal command -v if not a venv