shell脚本的android给出[:未找到脚本、未找到、shell、android

2023-09-06 16:47:30 作者:No Name

我有这个脚本,适用于我的Linux机器

I have this script which works on my linux machine

#!/bin/sh
c=1
if [ $c == 1 ]
then
  echo c is 1
else
  echo c is 0
fi

但是当我使用这在Android中,如下所示:

But when I use this in android as follows:

#!/system/bin/sh
c=1
if [ $c == 1 ]
then
  echo c is 1
else
  echo c is 0
fi

这给出了一个错误,如:

It gives an error like:

[: not found

修改

是否有任何其他的逻辑来检查 $ C 的价值,无论是1还是0?

Is there any other logic to check the value of $c, whether it is 1 or 0 ?

Android的壳有问题的[]中,如果那么有没有检查c的值任何其他方式?

推荐答案

一般 [的别名测试

在Linux机器的测试是在

in Linux machine test is at

/usr/bin/test

if [ $c == 1 ]

被评为

if test "$c" = 1

但是,这里的机器人有没有测试

BUT here in android there is no test

因此​​,如果用[]将不会在任何情况下工作...

so if with [] will not work in any case...

我将穿越为Android编写的测试,并检查它.... !!!

i will cross compile test for android and check it....!!!