• 给源代码自动加 license 头部


    function filtCodeFile()
    {
        filename="$1"
        filepath="$2/$1"
        blackList="Pods"
        if [[ $filepath =~ $blackList ]]; then
            return 1
        fi
        if [ "${filename##*.}" = "h" -o "${filename##*.}" == "m" ]; then
            if [ ! -z "`grep "MIT License" $filepath`" ]; then
                echo "[$filepath] aleady has license describe."
                #test
            else
                echo "/* " > ./copy_license_file.txt
                cat "./LICENSE" >> ./copy_license_file.txt
                echo " */" >> ./copy_license_file.txt
                cat "$filepath" >> ./copy_license_file.txt
                mv ./copy_license_file.txt $filepath
                echo "[$filepath] add license finish!"
            fi
        fi
    }
    
    function traversingFiles()
    {
        #1st param, the dir name
        for file in `ls $1`;
        do
            if [ -d "$1/$file" ]; then
                #filtCodeFile $file $1
                traversingFiles "$1/$file" "$1"
            else
                filtCodeFile $file $1
            fi
        done
        rm -f ./copy_license_file.txt
    }
    
    traversingFiles "."
  • 相关阅读:
    Alpha冲刺Day10
    Alpha冲刺Day9
    Alpha冲刺Day8
    Alpha冲刺Day7
    Alpha冲刺Day6
    SDN
    【Alpha
    【Alpha】团队课程展示
    【Alpha】团队项目测试报告与用户反馈
    【Alpha】总结
  • 原文地址:https://www.cnblogs.com/AkQuan/p/7306209.html
Copyright © 2020-2023  润新知