From 8d99a35f01191217966258b311a282a5a0ddcfae Mon Sep 17 00:00:00 2001 From: Afzal Ansari Date: Mon, 9 May 2022 08:53:45 +0530 Subject: [PATCH] Fix: Refactors shell to have double quotes format (#3830) * refactors double quote to prevent globbing and word splitting e2e sh Signed-off-by: afzal442 * refactors e2e_core sh Signed-off-by: afzal442 * refactors cleanup sh Signed-off-by: afzal442 * refactors header-chk sh Signed-off-by: afzal442 * refactors installdef sh Signed-off-by: afzal442 --- hack/crd/cleanup.sh | 10 +++++----- hack/e2e/end_e2e.sh | 8 ++++---- hack/e2e/end_e2e_core.sh | 8 ++++---- hack/licence/header-check.sh | 4 ++-- hack/utils/installdefinition.sh | 12 ++++++------ 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/hack/crd/cleanup.sh b/hack/crd/cleanup.sh index 744ee05c5..85b5c486b 100755 --- a/hack/crd/cleanup.sh +++ b/hack/crd/cleanup.sh @@ -3,15 +3,15 @@ set -e SCRIPT_DIR=$(dirname "$0") -pushd $SCRIPT_DIR +pushd "$SCRIPT_DIR" TEMPLATE_DIR="../../config/crd/base" echo "clean up unused fields of CRDs" -for filename in `ls $TEMPLATE_DIR`; do +for filename in `ls "$TEMPLATE_DIR"`; do - sed -i.bak '/creationTimestamp: null/d' ${TEMPLATE_DIR}/$filename + sed -i.bak '/creationTimestamp: null/d' "${TEMPLATE_DIR}/$filename" done @@ -19,9 +19,9 @@ rm ${TEMPLATE_DIR}/*.bak TEMPLATE_DIR="../../legacy/charts/vela-core-legacy/crds" -for filename in `ls $TEMPLATE_DIR`; do +for filename in `ls "$TEMPLATE_DIR"`; do - sed -i.bak '/creationTimestamp: null/d' ${TEMPLATE_DIR}/$filename + sed -i.bak '/creationTimestamp: null/d' "${TEMPLATE_DIR}/$filename" done diff --git a/hack/e2e/end_e2e.sh b/hack/e2e/end_e2e.sh index edabf74c6..77126a1c4 100644 --- a/hack/e2e/end_e2e.sh +++ b/hack/e2e/end_e2e.sh @@ -8,16 +8,16 @@ echo "${OAM_DOCKER_DIR}" docker exec kind-control-plane crictl exec "${OAM_CONTAINER_ID}" kill -2 1 file=$OAM_DOCKER_DIR/e2e-profile.out -echo $file +echo "$file" n=1 while [ $n -le 60 ];do if_exist=$(docker exec kind-control-plane sh -c "test -f $file && echo 'ok'") - echo $if_exist + echo "$if_exist" if [ -n "$if_exist" ];then - docker exec kind-control-plane cat $file > /tmp/oam-e2e-profile.out + docker exec kind-control-plane cat "$file" > /tmp/oam-e2e-profile.out break fi echo file not generated yet - n=$(expr $n + 1) + n="$(expr $n + 1)" sleep 1 done \ No newline at end of file diff --git a/hack/e2e/end_e2e_core.sh b/hack/e2e/end_e2e_core.sh index ccb37df6f..3f7eed726 100644 --- a/hack/e2e/end_e2e_core.sh +++ b/hack/e2e/end_e2e_core.sh @@ -6,16 +6,16 @@ echo "${DOCKER_DIR}" docker exec kind-control-plane crictl exec "${CONTAINER_ID}" kill -2 1 file=$DOCKER_DIR/e2e-profile.out -echo $file +echo "$file" n=1 while [ $n -le 60 ];do if_exist=$(docker exec kind-control-plane sh -c "test -f $file && echo 'ok'") - echo $if_exist + echo "$if_exist" if [ -n "$if_exist" ];then - docker exec kind-control-plane cat $file > /tmp/e2e-profile.out + docker exec kind-control-plane cat "$file" > /tmp/e2e-profile.out break fi echo file not generated yet - n=$(expr $n + 1) + n="$(expr $n + 1)" sleep 1 done diff --git a/hack/licence/header-check.sh b/hack/licence/header-check.sh index 298bd3bf9..7a83c5955 100755 --- a/hack/licence/header-check.sh +++ b/hack/licence/header-check.sh @@ -23,8 +23,8 @@ for file in $(git ls-files | grep "\.go$" | grep -v vendor/); do fi if [ $ERR == true ]; then if [[ $# -gt 0 && $1 =~ [[:upper:]fix] ]]; then - cat ../boilerplate.go.txt ${file} > ${file}.new - mv ${file}.new ${file} + cat ../boilerplate.go.txt "${file}" > "${file}".new + mv "${file}".new "${file}" echo "$(tput -T xterm setaf 3)FIXING$(tput -T xterm sgr0)" ERR=false else diff --git a/hack/utils/installdefinition.sh b/hack/utils/installdefinition.sh index 8af773634..0f0b92144 100755 --- a/hack/utils/installdefinition.sh +++ b/hack/utils/installdefinition.sh @@ -11,15 +11,15 @@ function check_install() { kubectl create namespace vela-system fi echo "applying definitions ..." - cd $DEF_PATH + cd "$DEF_PATH" for file in *.yaml ; do - echo "Info: changing "$DEF_PATH"/"$file - sed -i.bak "s#namespace: {{ include \"systemDefinitionNamespace\" . }}#namespace: vela-system#g" $file - kubectl apply -f $file - rm $file - mv $file".bak" $file + echo "Info: changing "$DEF_PATH"/""$file" + sed -i.bak "s#namespace: {{ include \"systemDefinitionNamespace\" . }}#namespace: vela-system#g" "$file" + kubectl apply -f "$file" + rm "$file" + mv "$file"".bak" "$file" done cd -