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

  • 相关阅读:
    wpf中的Border和Background
    人工智能-推荐数据处理
    【运维心得】ApacheDirectory找不到java路径的解决方案
    Springboot结合Freemaker导出模板doc和docx文件
    windows中关闭占用文件的程序
    揭开ChatGPT面纱(3):使用OpenAI进行文本情感分析(embeddings接口)
    一起来学Kotlin:概念:16. Kotlin Scope Function 作用域函数:let,run,with,apply,also
    ELMO语言模型
    单源最短路的建图
    Go语言并发编程——原子操作
  • 原文地址:https://blog.csdn.net/babytiger/article/details/126031646