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

  • 相关阅读:
    【Ascend310】【Mindspore】安装mindspore后无法进行跑通样例
    CSS盒子模型、列表样式
    VS2019创建GIt仓库时剔除文件或目录
    1 什么是Zookeeper 能干什么
    2023年9月青少年软件编程C语言三级真题及答案
    rk3399 linux4.19 ubuntu mpv播放概率性内核崩溃在vop_crtc_atomic_flush
    新的类功能 --- c++11
    RocketMQ知识点总结
    Spring注解-3.自动装配
    Lab 1 实验 MapReduce
  • 原文地址:https://blog.csdn.net/babytiger/article/details/126031646