From 8c3a53c3f416fbedde9c65a8e0fb01a9417683aa Mon Sep 17 00:00:00 2001 From: jdoe0 Date: Fri, 10 Jan 2014 19:34:12 +0700 Subject: [PATCH] ankisyncd.sh: Look for 'python2' before checking the version of 'python' --- ankisyncd.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ankisyncd.sh b/ankisyncd.sh index 75981c6..d92de0c 100755 --- a/ankisyncd.sh +++ b/ankisyncd.sh @@ -1,16 +1,21 @@ #! /usr/bin/env bash export PYTHONPATH="/usr/share/ankisyncd" -export PYTHON="python" +export PYTHON="python2" -if [ $(python -V 2>&1 | cut -d ' ' -f 2 | cut -d '.' -f 1) -ne 2 ]; then - which python2 > /dev/null +which python2 > /dev/null - if [ $? -eq 0 ]; then - PYTHON="python2" - else - echo "$0: Cannot find Python 2" 1>&2 - fi +if [ $? -ne 0 ]; then + which python > /dev/null + + if [ $? -ne 0 -a \ + $($PYTHON -V 2>&1 | cut -d ' ' -f 2 | cut -d '.' -f 1) -ne 2 ]; then + PYTHON="python" + else + echo "$0: Cannot find Python 2" 1>&2 + + exit 1 + fi fi $PYTHON /usr/share/ankisyncd/ankisyncd/sync_app.py