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

  • 相关阅读:
    selenium自动化测试-获取网页截图
    Ubuntu下Nginx配置ModSecurity详细思路及过程
    idea正常run,但是debug报错
    聚观早报 |联想集团Q2财季业绩;小鹏汽车Q3营收
    Azure Virtual Desktop(一)创建配置管理
    NoSQL之Redis配置与优化
    webpack5 之 构建vue3+js、vue3+ts、vue3 + vue-route、vue3 + pinia
    如何在jar包外设置配置文件
    集合原理简记
    基于Java的捐赠平台
  • 原文地址:https://blog.csdn.net/babytiger/article/details/126031646