0

我正在尝试使用此 shell 脚本从 ndk 获取详细的错误,如此处所述[link]。但是我遇到了一些错误,我不知道 shell 脚本,有人可以在这里帮助我吗?

代码

if [ $# -lt 1 ]
then
    echo usage: $0 app
    exit 0
fi

APP=$1
LOG_FILE=$2

if [ ! -n "${ANDROID_NDK}" ]
then
    ANDROID_NDK=`dirname $0`
    echo ANDROID_NDK is not set using ${ANDROID_NDK}
fi

ADDR2LINE=${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-eabi-addr2line


if [ ! -s $LOG_FILE ]
then
    echo File $LOG_FILE does not exist or empty.
    exit 0
fi

while read LINE
do
    echo $LINE

    if [[ $LINE =~ ^.+\#[0-9]{2}\ +pc\ +([0-9A-Fa-f]{8})\ +(.+\.so).?$ ]] 
    then
            ADDR=${BASH_REMATCH[1]}
            SO=`basename ${BASH_REMATCH[2]}`
            SRC=`${ADDR2LINE} -C -f -e ${ANDROID_NDK}/out/apps/${APP}/armeabi/$
{SO} ${ADDR} 2>/dev/null`
            echo ${SRC} 

输出

./stack.sh: line 42: conditional binary operator expected
./stack.sh: line 42: syntax error near `=~'
./stack.sh: line 42: `        if [[ $LINE =~ ^.+#[0-9]{2}\ +pc\ +([0-9A-Fa-f]{8})\ +(.+\.so).?$ ]] '
4

1 回答 1

0

=~运算符是在 Bash 版本 3 中添加的;您可能需要更新。

于 2013-08-30T09:02:21.883 回答