From 7136819979c9020ced3f42b35dc7706d10ea4ab8 Mon Sep 17 00:00:00 2001 From: Fei Yuan Date: Fri, 18 Mar 2016 03:03:19 -0400 Subject: [PATCH] Allow android-interact.sh to be run in another directory In order to source compatibility.sh, the working directory must be changed to the directory of the script. But finding the script's directory requires $REALPATH, which is defined in compatibility.sh. To break the cycle, the script now makes use of Python's os.path.realpath. --- android-interact.sh | 6 +++--- compatibility.sh | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/android-interact.sh b/android-interact.sh index da30c98..5676c9e 100755 --- a/android-interact.sh +++ b/android-interact.sh @@ -3,12 +3,12 @@ # Date: Fri Jun 26 10:38:07 2015 +0800 # Author: Yuxin Wu -source compatibility.sh - -PROG_NAME=`$REALPATH "$0"` +PROG_NAME=`python -c "import os, sys; print(os.path.realpath(sys.argv[1]))" "$0"` PROG_DIR=`dirname "$PROG_NAME"` cd "$PROG_DIR" +source compatibility.sh + # Please check that your path is the same, since this might be different among devices RES_DIR="/mnt/sdcard/tencent/MicroMsg" MM_DIR="/data/data/com.tencent.mm" diff --git a/compatibility.sh b/compatibility.sh index 0f99b4a..d910311 100755 --- a/compatibility.sh +++ b/compatibility.sh @@ -3,16 +3,10 @@ # $Date: Tue Jun 16 22:23:36 2015 +0800 # Author: Vury Leo -realpath() { - [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" -} - if [ `uname` = 'Darwin' ]; then - REALPATH='realpath' GREP='grep -E' MD5SUM='md5' else - REALPATH='readlink -f' GREP='grep -E' MD5SUM='md5sum' fi