Skip to content

Commit 09ef253

Browse files
committed
quote underquoted variable expansions
This protects against word splitting if the variable contains IFS characters, and it ensures that an empty variable doesn't become an elided argument.
1 parent c100a04 commit 09ef253

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

tools/build_test_env.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ cleanup() {
5555
docker kill gitlab-test >/dev/null 2>&1
5656
docker rm gitlab-test >/dev/null 2>&1
5757
command -v deactivate >/dev/null 2>&1 && deactivate || true
58-
rm -rf $VENV
58+
rm -rf "$VENV"
5959
}
6060
[ -z "${BUILD_TEST_ENV_AUTO_CLEANUP+set}" ] || {
6161
trap cleanup EXIT
@@ -68,10 +68,10 @@ docker run --name gitlab-test --detach --publish 8080:80 \
6868
LOGIN='root'
6969
PASSWORD='5iveL!fe'
7070
CONFIG=/tmp/python-gitlab.cfg
71-
GITLAB() { gitlab --config-file $CONFIG "$@"; }
71+
GITLAB() { gitlab --config-file "$CONFIG" "$@"; }
7272
GREEN='\033[0;32m'
7373
NC='\033[0m'
74-
OK() { echo -e ${GREEN}OK${NC}; }
74+
OK() { echo -e "${GREEN}OK${NC}"; }
7575

7676
log "Waiting for gitlab to come online... "
7777
I=0
@@ -82,7 +82,7 @@ while :; do
8282
curl -s http://localhost:8080/users/sign_in 2>/dev/null \
8383
| grep -q "GitLab Community Edition" && break
8484
let I=I+5
85-
[ $I -eq 120 ] && exit 1
85+
[ "$I" -eq 120 ] && exit 1
8686
done
8787
sleep 5
8888

@@ -106,8 +106,8 @@ EOF
106106
log "Config file content ($CONFIG):"
107107
log <$CONFIG
108108

109-
$VENV_CMD $VENV
110-
. $VENV/bin/activate
109+
"$VENV_CMD" "$VENV"
110+
. "$VENV"/bin/activate
111111
pip install -rrequirements.txt
112112
pip install -e .
113113

tools/functional_tests.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# You should have received a copy of the GNU Lesser General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
setenv_script=$(dirname $0)/build_test_env.sh
17+
setenv_script=$(dirname "$0")/build_test_env.sh
1818
BUILD_TEST_ENV_AUTO_CLEANUP=true
19-
. $setenv_script "$@"
19+
. "$setenv_script" "$@"
2020

2121
set -e
2222

@@ -27,7 +27,7 @@ GITLAB project list | grep -q test-project1
2727
OK
2828

2929
echo -n "Testing project update... "
30-
GITLAB project update --id $PROJECT_ID --description "My New Description"
30+
GITLAB project update --id "$PROJECT_ID" --description "My New Description"
3131
OK
3232

3333
echo -n "Testing user creation... "
@@ -44,37 +44,37 @@ GITLAB -v user list | grep -qv config-file
4444
OK
4545

4646
echo -n "Testing adding member to a project... "
47-
GITLAB project-member create --project-id $PROJECT_ID \
48-
--user-id $USER_ID --access-level 40 >/dev/null 2>&1
47+
GITLAB project-member create --project-id "$PROJECT_ID" \
48+
--user-id "$USER_ID" --access-level 40 >/dev/null 2>&1
4949
OK
5050

5151
echo -n "Testing file creation... "
52-
GITLAB project-file create --project-id $PROJECT_ID \
52+
GITLAB project-file create --project-id "$PROJECT_ID" \
5353
--file-path README --branch-name master --content "CONTENT" \
5454
--commit-message "Initial commit" >/dev/null 2>&1
5555
OK
5656

5757
echo -n "Testing issue creation... "
58-
ISSUE_ID=$(GITLAB project-issue create --project-id $PROJECT_ID \
58+
ISSUE_ID=$(GITLAB project-issue create --project-id "$PROJECT_ID" \
5959
--title "my issue" --description "my issue description" \
6060
| grep ^id: | cut -d' ' -f2)
6161
OK
6262

6363
echo -n "Testing note creation... "
64-
GITLAB project-issue-note create --project-id $PROJECT_ID \
65-
--issue-id $ISSUE_ID --body "the body" >/dev/null 2>&1
64+
GITLAB project-issue-note create --project-id "$PROJECT_ID" \
65+
--issue-id "$ISSUE_ID" --body "the body" >/dev/null 2>&1
6666
OK
6767

6868
echo -n "Testing branch creation... "
69-
GITLAB project-branch create --project-id $PROJECT_ID \
69+
GITLAB project-branch create --project-id "$PROJECT_ID" \
7070
--branch-name branch1 --ref master >/dev/null 2>&1
7171
OK
7272

7373
echo -n "Testing branch deletion... "
74-
GITLAB project-branch delete --project-id $PROJECT_ID \
74+
GITLAB project-branch delete --project-id "$PROJECT_ID" \
7575
--name branch1 >/dev/null 2>&1
7676
OK
7777

7878
echo -n "Testing project deletion... "
79-
GITLAB project delete --id $PROJECT_ID
79+
GITLAB project delete --id "$PROJECT_ID"
8080
OK

tools/py_functional_tests.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# You should have received a copy of the GNU Lesser General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
setenv_script=$(dirname $0)/build_test_env.sh
17+
setenv_script=$(dirname "$0")/build_test_env.sh
1818
BUILD_TEST_ENV_AUTO_CLEANUP=true
19-
. $setenv_script "$@"
19+
. "$setenv_script" "$@"
2020

21-
python $(dirname $0)/python_test.py
21+
python "$(dirname "$0")"/python_test.py

0 commit comments

Comments
 (0)