From 3d2204bd8be52fda1c2bf75cf1afa7b6947c4ab2 Mon Sep 17 00:00:00 2001 From: Seokyong Jung <76677409+syjung6967@users.noreply.github.com> Date: Wed, 19 May 2021 00:14:22 +0900 Subject: [PATCH 1/2] Less indent and check valid python more strictly --- guider/guider | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/guider/guider b/guider/guider index a37ec493..989562e7 100755 --- a/guider/guider +++ b/guider/guider @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Guider Launcher # # Copyright (c) 2016-2021 Peace Lee @@ -7,22 +9,14 @@ # Software Foundation; either version 2 of the License, or (at your option) # any later version. -# check python # -if [ ! $PYTHON ] +# check valid Python in order: user-specified, python, python3 and 2 # +if [ z`$PYTHON -V 2>/dev/null | cut -d' ' -f1` != "zPython" ] then - PYTHON=$(which python) - if [ ! $PYTHON ] + PYTHON=`which python || which python3 || which python2` + if [ z`$PYTHON -V 2>/dev/null | cut -d' ' -f1` != "zPython" ] then - PYTHON=$(which python3) - if [ ! $PYTHON ] - then - PYTHON=$(which python2) - if [ ! $PYTHON ] - then - echo "[Error] fail to find python" - exit - fi - fi + echo "[Error] fail to find python" + exit fi fi From 73b6c048ef34345bed3c86187cfc4aadcfe388b6 Mon Sep 17 00:00:00 2001 From: Seokyong Jung <76677409+syjung6967@users.noreply.github.com> Date: Wed, 19 May 2021 00:49:12 +0900 Subject: [PATCH 2/2] check all executable files in one line --- guider/guider | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/guider/guider b/guider/guider index 989562e7..57295d34 100755 --- a/guider/guider +++ b/guider/guider @@ -10,14 +10,11 @@ # any later version. # check valid Python in order: user-specified, python, python3 and 2 # +PYTHON=`which $PYTHON || which python || which python3 || which python2` if [ z`$PYTHON -V 2>/dev/null | cut -d' ' -f1` != "zPython" ] then - PYTHON=`which python || which python3 || which python2` - if [ z`$PYTHON -V 2>/dev/null | cut -d' ' -f1` != "zPython" ] - then - echo "[Error] fail to find python" - exit - fi + echo "[Error] fail to find python" + exit fi # export CMDLINE for Guider #