sh脚本中magisk下的/data/adb/service.d中不支持数组

在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脚本不支持数组访问,所以要把循环改为一

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值