adb shell输入文本不带&符号字符

a.t*_*ddy 3 android adb

当我输入带有&字符的文本时,我的完整文本将进入编辑框.

D:\ Apps\Android-SDK\tools> adb shell输入文本hello&hello'hello'未被识别为内部或外部命令,可运行程序或批处理文件.

它只是打招呼.但是没有输入其他&和你好的字符.

当我键入以下adb设备和adb设备时它将提供2个输出.

adb shell输入文本值应采用其他格式,例如引号或其他内容.

我怎样才能输入这个值和字符?

Jon*_*win 6

( ) < > | ; & * \\ ~ " \'和空格都需要转义。\n空格可以替换为%s.

\n\n

我已经编写了一个 android 命令行工具来执行此调用inputer
\n我的代码中的函数在这里(使用regex):

\n\n
//e.g. convert string "hello world\\n" to string "hello%sworld\\n"\n    char * convert(char * trans_string)\n    {\n        char *s0 = replace(trans_string, \'\\\\\', "\\\\\\\\");\n        free(trans_string);\n        char *s = replace(s0, \'%\', "\\\\\\%");\n        free(s0);\n        char *s1 = replace(s, \' \', "%s");//special case for SPACE\n        free(s);\n        char *s2 = replace(s1, \'\\"\', "\\\\\\"");\n        free(s1);\n        char *s3 = replace(s2, \'\\\'\', "\\\\\\\'");\n        free(s2);\n        char *s4 = replace(s3, \'\\(\', "\\\\\\(");\n        free(s3);\n        char *s5 = replace(s4, \'\\)\', "\\\\\\)");\n        free(s4);\n        char *s6 = replace(s5, \'\\&\', "\\\\\\&");\n        free(s5);\n        char *s7 = replace(s6, \'\\<\', "\\\\\\<");\n        free(s6);\n        char *s8 = replace(s7, \'\\>\', "\\\\\\>");\n        free(s7);\n        char *s9 = replace(s8, \'\\;\', "\\\\\\;");\n        free(s8);\n        char *s10 = replace(s9, \'\\*\', "\\\\\\*");\n        free(s9);\n        char *s11 = replace(s10, \'\\|\', "\\\\\\|");\n        free(s10);\n        char *s12 = replace(s11, \'\\~\', "\\\\\\~");\n        //this if un-escaped gives current directory !\n        free(s11);\n        char *s13 = replace(s12, \'\\\xc2\xac\', "\\\\\\\xc2\xac");\n        free(s12);\n        char *s14 = replace(s13, \'\\`\', "\\\\\\`");\n        free(s13);\n    //  char *s15 = replace(s14, \'\\\xc2\xa6\', "\\\\\\\xc2\xa6");\n    //  free(s14);\n        return s14;\n}\n
Run Code Online (Sandbox Code Playgroud)\n


Ste*_*hen 5

您需要将您的字符串封装在引号中并转义您的&符号 "hello\&hello"