From e42cb4f4cd513f512397ff7a46b6174b39a9708e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 26 Sep 2025 00:09:46 +0100 Subject: 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 --- include/init.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'include/init.sh') 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 -- cgit v1.2.1