0

I have a bash script which checks for a paticular string and proceeds further but seems to be getting some error with binary operator expected

    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

1 Answer 1

1

I know what your problem is, you must be using the new test operator [[. [http://mywiki.wooledge.org/BashFAQ/031][bash new test details]

if [[ "${branch_name}" =~ ^atf-rc-.* ]]; then
              env=atf-stage1;
            fi
Sign up to request clarification or add additional context in comments.

1 Comment

You can also avoid regex altogether by using globbing: if [[ $ci_commit_ref_name = atf-rc-* ]]; then

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.