获取 adb shell 命令的结果代码 [英] Get result code of adb shell command
本文介绍了获取 adb shell 命令的结果代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该如何获得adb shell
$?
的
?
我想检查adb shell mkdir/xxx
的结果.
我通过 adb shell
执行了 mkdir
命令并失败了,但是 $?
的结果是 0
.
I executed mkdir
command by adb shell
and failed but the result of $?
is 0
.
$ adb shell mkdir /xxx
mkdir failed for /xxx, Read-only file system
$ adb shell echo $?
0
$ adb shell "mkdir /xxx; echo $?"
mkdir failed for /xxx, Read-only file system
0
我想获得adb shell
但不是在交互模式的结果代码,如下所示:
I would like to get the result code of adb shell <command>
but not in the interactive mode like below:
$ adb shell
shell@android:/ $ mkdir /xxx
mkdir failed for /xxx, Read-only file system
255|shell@android:/ $ echo $?
255
推荐答案
你应该这样做:
$ adb shell 'mkdir /xxx; echo $?'
mkdir failed for /xxx, Read-only file system
255
注意单引号,否则 $?
在到达 adb 之前被评估.
Notice the single quotes, otherwise $?
is evaluated before reaching adb.
这篇关于获取 adb shell 命令的结果代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文