簡體   English   中英

bash腳本失敗,預期二進制運算符

[英]bash script fails with binary operator expected

我有一個bash腳本,用於檢查特定字符串,並繼續進行操作,但是似乎在使用二進制運算符時出現了一些錯誤

    local artifacts=$(realpath artifacts)/middle-end
    local env
    local account_id=${1}
    local branch_name=${2}
    local user_environments=${3}
    local gitlab_user_id=${4}
    env=$(ci/scripts/get-details-env.py -m "${user_environments}" -u "${user_id}")

    # Deploy to int1 from develop
    echo "$branch_name"
    if [ "${branch_name}" == "develop" ]; then
      env=brt-int;
    fi
    if [ "${branch_name}" =~ ^brt-rc-.* ]; then
      env=brt-uat;
    fi

    mkdir -p ${artifacts}
    cd middle-end
    ln -s ${NODE_PATH} ./node_modules
    npm run build

我知道您的問題是什么,您必須使用新的測試運算符[[ [ http://mywiki.wooledge.org/BashFAQ/031 ] [ 打擊新測試詳細信息]

if [[ "${branch_name}" =~ ^atf-rc-.* ]]; then
              env=atf-stage1;
            fi

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM