Skip to content

Commit 0e5395e

Browse files
committed
[NRL-1922] Use [[ instead of [ for conditions in shell scripts
1 parent 85f441e commit 0e5395e

6 files changed

Lines changed: 13 additions & 13 deletions

scripts/bootstrap.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function _bootstrap_help() {
2828
}
2929

3030
function _check_mgmt() {
31-
if [ "$(aws iam list-account-aliases --query 'AccountAliases[0]' --output text)" != "nhsd-ddc-spine-nrlf-mgmt" ]; then
31+
if [[ "$(aws iam list-account-aliases --query 'AccountAliases[0]' --output text)" != "nhsd-ddc-spine-nrlf-mgmt" ]]; then
3232
echo "Please log in as the mgmt account" >&2
3333
return 1
3434
fi
@@ -98,7 +98,7 @@ function _bootstrap() {
9898
set +e
9999
mgmt_account_id=$(aws secretsmanager get-secret-value --secret-id "${MGMT_ACCOUNT_ID_LOCATION}" --query SecretString --output text)
100100

101-
if [ "${mgmt_account_id}" == "" ]; then
101+
if [[ "${mgmt_account_id}" == "" ]]; then
102102
aws secretsmanager create-secret --name "${MGMT_ACCOUNT_ID_LOCATION}"
103103
echo "Please set ${MGMT_ACCOUNT_ID_LOCATION} in the Secrets Manager and rerun the script"
104104
exit 1

scripts/check-build-environment.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -o errexit -o pipefail -o nounset
66
: "${SHOULD_WARN_ONLY:="false"}"
77

88
function success() {
9-
[ "${SHOULD_WARN_ONLY}" == "true" ] && return
9+
[[ "${SHOULD_WARN_ONLY}" == "true" ]] && return
1010

1111
local message="$1"
1212
echo "${message}"
@@ -38,7 +38,7 @@ for dep in ${BUILD_DEPENDENCIES}; do
3838
dep_path="$(which ${dep} 2> /dev/null)"
3939
set -e
4040

41-
if [ -n "${dep_path}" -a -x "${dep_path}" ]
41+
if [[ -n "${dep_path}" -a -x "${dep_path}" ]]
4242
then
4343
success "${dep} found at ${dep_path}"
4444
else

scripts/check-deploy-environment.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set -o errexit -o pipefail -o nounset
99
: "${TF_WORKSPACE_NAME:=""}"
1010

1111
function success() {
12-
[ "${SHOULD_WARN_ONLY}" == "true" ] && return
12+
[[ "${SHOULD_WARN_ONLY}" == "true" ]] && return
1313

1414
local message="$1"
1515
echo "${message}"
@@ -33,7 +33,7 @@ for dep in ${DEPLOY_DEPENDENCIES}; do
3333
dep_path="$(which ${dep} 2> /dev/null)"
3434
set -e
3535

36-
if [ -n "${dep_path}" -a -x "${dep_path}" ]
36+
if [[ -n "${dep_path}" -a -x "${dep_path}" ]]
3737
then
3838
success "${dep} found at ${dep_path}"
3939
else
@@ -45,7 +45,7 @@ done
4545
set +e
4646
env_account_id="$(aws secretsmanager get-secret-value --secret-id nhsd-nrlf--mgmt--${ENV_ACCOUNT_NAME}-account-id --query SecretString --output text)"
4747
set -e
48-
if [ -n "${env_account_id}" ]
48+
if [[ -n "${env_account_id}" ]]
4949
then
5050
success "${ENV_ACCOUNT_NAME} account id found in mgmt account"
5151
else
@@ -59,7 +59,7 @@ tf_workspace="$(cd terraform/infrastructure && terraform workspace show)"
5959
set -e
6060

6161
is_using_shared_resources="$(poetry run python ./scripts/are_resources_shared_for_stack.py ${tf_workspace})"
62-
if [ "${is_using_shared_resources}" == "true" ]
62+
if [[ "${is_using_shared_resources}" == "true" ]]
6363
then
6464
warning "Will use shared resources for stack '${tf_workspace}'"
6565
else

scripts/get-account-name-for-env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Get the account name for the provided NRLF environment
33
set -o errexit -o nounset -o pipefail
44

5-
if [ $# -ne 1 ]; then
5+
if [[ $# -ne 1 ]]; then
66
echo "Usage: get-account-name-for-env.sh <env>"
77
exit 1
88
fi

scripts/get-current-info.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
66
TAG_NAME="$(git describe --tags || echo "no-tags")"
77
SHORT_COMMIT_HASH="$(git rev-parse --short=8 HEAD)"
88

9-
if [ "${BRANCH_NAME}" == "HEAD" ]; then
9+
if [[ "${BRANCH_NAME}" == "HEAD" ]]; then
1010
NRLF_VERSION="${TAG_NAME}@${SHORT_COMMIT_HASH}"
1111
else
1212
NRLF_VERSION="${BRANCH_NAME}@${SHORT_COMMIT_HASH}"

scripts/pull-lambda-code-for-stack.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -o errexit -o nounset -o pipefail
44

55
: "${DIST_DIR:="./dist"}"
66

7-
if [ $# -ne 1 ]
7+
if [[ $# -ne 1 ]]
88
then
99
echo "Error: stack-name argument is missing" 1>&2
1010
echo "Usage: $0 <stack-name>" 1>&2
@@ -44,7 +44,7 @@ echo
4444
echo "Pulling code for consumer API lambdas...."
4545
for endpoint_path in api/consumer/*
4646
do
47-
if [ ! -d "${endpoint_path}" ]
47+
if [[ ! -d "${endpoint_path}" ]]
4848
then
4949
continue
5050
fi
@@ -57,7 +57,7 @@ echo
5757
echo "Pulling code for producer API lambdas...."
5858
for endpoint_path in api/producer/*
5959
do
60-
if [ ! -d "${endpoint_path}" ]
60+
if [[ ! -d "${endpoint_path}" ]]
6161
then
6262
continue
6363
fi

0 commit comments

Comments
 (0)