Diff命令停止执行shell脚本

时间:2018-12-04 10:04:46

标签: linux shell scripting diff

我正在创建一个脚本来比较两个目录:

    for qa_branch in $QA_BRANCHES
    do
        exist_px=false
        info "1qa: $qa_branch"

        for px_branch in $PX_BRANCHES
        do
            info "2px: $px_branch"
            if [ "$qa_branch" = "$px_branch" ]; then
                exist_px=true

                cd test1
                checkout_branch "$qa_branch" || error "branch does not exist"
                cd ..

                cd test2    
                checkout_branch "$px_branch" || error "branch does not exist"
                cd ..

                echo
                info "compare_branches QA: $qa_branch with PX: $px_branch"
                diff -r --exclude=".*" test1/  test2/ 
                info "########################################################################"
            fi
        done
        info $exist_px
        echo
    done

当执行到达 diff 命令时,它将停止并且脚本的执行不会继续。我该如何解决?

想法是捕获差异并通过电子邮件发送差异。

谢谢!

0 个答案:

没有答案