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.
This commit is contained in:
Fei Yuan
2016-03-18 03:08:10 -04:00
parent 2d928222c6
commit 7136819979
2 changed files with 3 additions and 9 deletions
+3 -3
View File
@@ -3,12 +3,12 @@
# Date: Fri Jun 26 10:38:07 2015 +0800
# Author: Yuxin Wu <[email protected]>
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"
-6
View File
@@ -3,16 +3,10 @@
# $Date: Tue Jun 16 22:23:36 2015 +0800
# Author: Vury Leo <i[at]vuryleo[dot]com>
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