在ARM开发板中都会有sh,这是随busybox携带的脚本工具。当然,如果是完整版的busybox,里面也会有bash,在系统启动前
#sh脚本是不支持数据组的,下面代码会崩溃 #arr=(she is a beautiful girl) #echo $whoami $time begin init array finished >> /data/local/tmp/reboot.log ## shellcheck disable=SC2068 #for str in ${arr[@]};do #echo $str >> /data/local/tmp/reboot.log #done #echo $whoami $time init array finished >> /data/local/tmp/reboot.log #下面这种写法在magisk的sh中不支持 #whiteLists=( #com.sermux #com.heytap.browser #com.tencent.mobileqq #) # #下面这种写法在magisk的sh中不支持 #whiteLists[0]="com.sermux" #whiteLists[1]="com.heytap.browser" #whiteLists[2]="com.tencent.mobileqq" #whiteListString="com.sermux com.heytap.browser com.tencent.mobileqq" ## shellcheck disable=SC2068 #for str in ${whiteListString[@]};do #echo $str #done #echo $whoami $time test string finished >> /data/local/tmp/reboot.log #这里赋值时不能有空格存在 whiteLists="com.sermux com.heytap.browser com.tencent.mobileqq" echo $whoami $time 4 test ${whiteLists} >> /data/local/tmp/reboot.log echo $whoami $time 5 whiteLists=${whiteLists} >> /data/local/tmp/reboot.log #whiteListlength=${#whiteListString[@]} 这句话在magisk下面会崩溃 #whiteListlength=${#whiteListString[@]} whiteListlength=3 echo $whoami $time 6 whiteListlength=${whiteListlength} >> /data/local/tmp/reboot.log #echo whiteLists[0]=${whiteLists[0]} # ${whiteLists[0]} 会引起崩溃 echo $whoami $time 7 whiteLists >> /data/local/tmp/reboot.log ##shell数组起始为0开始,故长度减1,seq起始为1,所以设定seq起始为0以应对数组 whiteListlength=`expr $whiteListlength - 1` echo $whoami $time 8 whiteListlength=${whiteListlength} >> /data/local/tmp/reboot.log
因为在magisk下面sh脚本不支持数组访问,所以要把循环改为一