Browse code

Shell scripts: fix bare variables

This makes my IDE a bit more silent :-)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2019/01/10 10:50:47
Showing 24 changed files
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/env bash
1
+#!/bin/sh
2 2
 set -e
3 3
 
4 4
 # DinD: a wrapper script which allows docker to be run inside a docker container.
... ...
@@ -28,9 +28,9 @@ install_containerd() {
28 28
 		make
29 29
 	)
30 30
 
31
-	mkdir -p ${PREFIX}
31
+	mkdir -p "${PREFIX}"
32 32
 
33
-	cp bin/containerd ${PREFIX}/containerd
34
-	cp bin/containerd-shim ${PREFIX}/containerd-shim
35
-	cp bin/ctr ${PREFIX}/ctr
33
+	cp bin/containerd "${PREFIX}/containerd"
34
+	cp bin/containerd-shim "${PREFIX}/containerd-shim"
35
+	cp bin/ctr "${PREFIX}/ctr"
36 36
 }
... ...
@@ -8,14 +8,13 @@ install_dockercli() {
8 8
 
9 9
 	arch=$(uname -m)
10 10
 	# No official release of these platforms
11
-	if [[ "$arch" != "x86_64" ]] && [[ "$arch" != "s390x" ]]; then
11
+	if [ "$arch" != "x86_64" ] && [ "$arch" != "s390x" ]; then
12 12
 		build_dockercli
13 13
 		return
14 14
 	fi
15 15
 
16 16
 	url=https://download.docker.com/linux/static
17
-	curl -Ls $url/$DOCKERCLI_CHANNEL/$arch/docker-$DOCKERCLI_VERSION.tgz | \
18
-	tar -xz docker/docker
17
+	curl -Ls "${url}/${DOCKERCLI_CHANNEL}/${arch}/docker-${DOCKERCLI_VERSION}.tgz" | tar -xz docker/docker
19 18
 	mkdir -p ${PREFIX}
20 19
 	mv docker/docker ${PREFIX}/
21 20
 	rmdir docker
... ...
@@ -27,5 +26,5 @@ build_dockercli() {
27 27
 	git checkout -q "v$DOCKERCLI_VERSION"
28 28
 	mkdir -p "$GOPATH/src/github.com/docker"
29 29
 	mv components/cli "$GOPATH/src/github.com/docker/cli"
30
-	go build -buildmode=pie -o ${PREFIX}/docker github.com/docker/cli/cmd/docker
30
+	go build -buildmode=pie -o "${PREFIX}/docker" "github.com/docker/cli/cmd/docker"
31 31
 }
... ...
@@ -7,6 +7,6 @@ install_gometalinter() {
7 7
 	go get -d github.com/alecthomas/gometalinter
8 8
 	cd "$GOPATH/src/github.com/alecthomas/gometalinter"
9 9
 	git checkout -q "$GOMETALINTER_COMMIT"
10
-	go build -buildmode=pie -o ${PREFIX}/gometalinter github.com/alecthomas/gometalinter
11
-	GOBIN=${PREFIX} ${PREFIX}/gometalinter --install
10
+	go build -buildmode=pie -o "${PREFIX}/gometalinter" "github.com/alecthomas/gometalinter"
11
+	GOBIN=${PREFIX} "${PREFIX}/gometalinter" --install
12 12
 }
... ...
@@ -26,5 +26,5 @@ if [ ! -f "${dir}/${bin}.installer" ]; then
26 26
 	exit 1
27 27
 fi
28 28
 
29
-. $dir/$bin.installer
30
-install_$bin "$@"
29
+. ${dir}/${bin}.installer
30
+install_${bin} "$@"
... ...
@@ -32,7 +32,7 @@ _install_proxy() {
32 32
 	git clone https://github.com/docker/libnetwork.git "$GOPATH/src/github.com/docker/libnetwork"
33 33
 	cd "$GOPATH/src/github.com/docker/libnetwork"
34 34
 	git checkout -q "$LIBNETWORK_COMMIT"
35
-	go build $BUILD_MODE -ldflags="$PROXY_LDFLAGS" -o ${PREFIX}/docker-proxy github.com/docker/libnetwork/cmd/proxy
35
+	go build ${BUILD_MODE} -ldflags="$PROXY_LDFLAGS" -o ${PREFIX}/docker-proxy github.com/docker/libnetwork/cmd/proxy
36 36
 }
37 37
 
38 38
 
... ...
@@ -25,6 +25,6 @@ install_runc() {
25 25
 		target="$1"
26 26
 	fi
27 27
 	make BUILDTAGS="$RUNC_BUILDTAGS" "$target"
28
-	mkdir -p ${PREFIX}
29
-	cp runc ${PREFIX}/runc
28
+	mkdir -p "${PREFIX}"
29
+	cp runc "${PREFIX}/runc"
30 30
 }
... ...
@@ -9,6 +9,6 @@ install_tini() {
9 9
 	git checkout -q "$TINI_COMMIT"
10 10
 	cmake .
11 11
 	make tini-static
12
-	mkdir -p ${PREFIX}
13
-	cp tini-static ${PREFIX}/docker-init
12
+	mkdir -p "${PREFIX}"
13
+	cp tini-static "${PREFIX}/docker-init"
14 14
 }
... ...
@@ -8,5 +8,5 @@ install_tomlv() {
8 8
 	echo "Install tomlv version $TOMLV_COMMIT"
9 9
 	git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml"
10 10
 	cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT"
11
-	go build -v -buildmode=pie -o ${PREFIX}/tomlv github.com/BurntSushi/toml/cmd/tomlv
11
+	go build -v -buildmode=pie -o "${PREFIX}/tomlv" "github.com/BurntSushi/toml/cmd/tomlv"
12 12
 }
... ...
@@ -7,5 +7,5 @@ install_vndr() {
7 7
 	git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr"
8 8
 	cd "$GOPATH/src/github.com/LK4D4/vndr"
9 9
 	git checkout -q "$VNDR_COMMIT"
10
-	go build -buildmode=pie -v -o ${PREFIX}/vndr .
10
+	go build -buildmode=pie -v -o "${PREFIX}/vndr" .
11 11
 }
... ...
@@ -148,7 +148,7 @@ EXTLDFLAGS_STATIC='-static'
148 148
 ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
149 149
 # see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
150 150
 
151
-BUILDFLAGS=( $BUILDFLAGS "${ORIG_BUILDFLAGS[@]}" )
151
+BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" )
152 152
 
153 153
 # Test timeout.
154 154
 if [ "${DOCKER_ENGINE_GOARCH}" == "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" == "arm" ]; then
... ...
@@ -68,7 +68,7 @@ go build \
68 68
 		$LDFLAGS_STATIC_DOCKER
69 69
 		$DOCKER_LDFLAGS
70 70
 	" \
71
-	$GO_PACKAGE
71
+	${GO_PACKAGE}
72 72
 )
73 73
 
74 74
 echo "Created binary: $DEST/$BINARY_FULLNAME"
... ...
@@ -67,7 +67,7 @@ if [ "$(go env GOOS)" = "windows" ]; then
67 67
 	[ ! -z $GITCOMMIT ]    && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\""
68 68
 
69 69
 	function makeres {
70
-		$WINDRES \
70
+		${WINDRES} \
71 71
 			-i hack/make/.resources-windows/$1 \
72 72
 			-o $3 \
73 73
 			-F $2 \
... ...
@@ -76,7 +76,7 @@ if [ "$(go env GOOS)" = "windows" ]; then
76 76
 			$defs
77 77
 	}
78 78
 
79
-	$WINDMC \
79
+	${WINDMC} \
80 80
 		hack/make/.resources-windows/event_messages.mc \
81 81
 		-h autogen/winresources/tmp \
82 82
 		-r autogen/winresources/tmp
... ...
@@ -86,8 +86,8 @@ if [ -z "$DOCKER_TEST_HOST" ]; then
86 86
 			--storage-driver "$DOCKER_GRAPHDRIVER" \
87 87
 			--pidfile "$DEST/docker.pid" \
88 88
 			--userland-proxy="$DOCKER_USERLANDPROXY" \
89
-			$storage_params \
90
-			$extra_params \
89
+			${storage_params} \
90
+			${extra_params} \
91 91
 				&> "$DEST/docker.log"
92 92
 	) &
93 93
 else
... ...
@@ -97,7 +97,7 @@ fi
97 97
 # give it a little time to come up so it's "ready"
98 98
 tries=60
99 99
 echo "INFO: Waiting for daemon to start..."
100
-while ! $TEST_CLIENT_BINARY version &> /dev/null; do
100
+while ! ${TEST_CLIENT_BINARY} version &> /dev/null; do
101 101
 	(( tries-- ))
102 102
 	if [ $tries -le 0 ]; then
103 103
 		printf "\n"
... ...
@@ -106,7 +106,7 @@ while ! $TEST_CLIENT_BINARY version &> /dev/null; do
106 106
 			echo >&2 "  check $DEST/docker.log for details"
107 107
 		else
108 108
 			echo >&2 "error: daemon at $DOCKER_HOST fails to '$TEST_CLIENT_BINARY version':"
109
-			$TEST_CLIENT_BINARY version >&2 || true
109
+			${TEST_CLIENT_BINARY} version >&2 || true
110 110
 			# Additional Windows CI debugging as this is a common error as of
111 111
 			# January 2016
112 112
 			if [ "$(go env GOOS)" = 'windows' ]; then
... ...
@@ -5,7 +5,7 @@
5 5
 #
6 6
 #     TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration
7 7
 #
8
-if [ -z $MAKEDIR ]; then
8
+if [ -z ${MAKEDIR} ]; then
9 9
 	export MAKEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10 10
 fi
11 11
 source "$MAKEDIR/.go-autogen"
... ...
@@ -26,11 +26,11 @@ run_test_integration() {
26 26
 
27 27
 run_test_integration_suites() {
28 28
 	local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS"
29
-	for dir in $integration_api_dirs; do
29
+	for dir in ${integration_api_dirs}; do
30 30
 		if ! (
31
-			cd $dir
31
+			cd "$dir"
32 32
 			echo "Running $PWD"
33
-			test_env ./test.main $flags
33
+			test_env ./test.main ${flags}
34 34
 		); then exit 1; fi
35 35
 	done
36 36
 }
... ...
@@ -50,7 +50,7 @@ build_test_suite_binaries() {
50 50
 		return
51 51
 	fi
52 52
 	build_test_suite_binary ./integration-cli "test.main"
53
-	for dir in $integration_api_dirs; do
53
+	for dir in ${integration_api_dirs}; do
54 54
 		build_test_suite_binary "$dir" "test.main"
55 55
 	done
56 56
 }
... ...
@@ -70,7 +70,7 @@ cleanup_test_suite_binaries() {
70 70
 }
71 71
 
72 72
 repeat() {
73
-	for i in $(seq 1 $TEST_REPEAT); do
73
+	for i in $(seq 1 ${TEST_REPEAT}); do
74 74
 		echo "Running integration-test (iteration $i)"
75 75
 		$@
76 76
 	done
... ...
@@ -115,7 +115,7 @@ error_on_leaked_containerd_shims() {
115 115
 	            awk '$2 == "containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }')
116 116
 	if [ -n "$leftovers" ]; then
117 117
 		ps aux
118
-		kill -9 $leftovers 2> /dev/null
118
+		kill -9 ${leftovers} 2> /dev/null
119 119
 		echo "!!!! WARNING you have left over shim(s), Cleanup your test !!!!"
120 120
 		exit 1
121 121
 	fi
... ...
@@ -2,28 +2,28 @@
2 2
 set -e
3 3
 
4 4
 # if we have our linux/amd64 version compiled, let's symlink it in
5
-if [ -x "$DEST/../binary-daemon/dockerd-$VERSION" ]; then
5
+if [ -x "${DEST}/../binary-daemon/dockerd-${VERSION}" ]; then
6 6
 	arch=$(go env GOHOSTARCH)
7 7
 	mkdir -p "$DEST/linux/${arch}"
8 8
 	(
9
-		cd "$DEST/linux/${arch}"
9
+		cd "${DEST}/linux/${arch}"
10 10
 		ln -sf ../../../binary-daemon/* ./
11 11
 	)
12
-	echo "Created symlinks:" "$DEST/linux/${arch}/"*
12
+	echo "Created symlinks:" "${DEST}/linux/${arch}/"*
13 13
 fi
14 14
 
15 15
 DOCKER_CROSSPLATFORMS=${DOCKER_CROSSPLATFORMS:-"linux/amd64 windows/amd64"}
16 16
 
17
-for platform in $DOCKER_CROSSPLATFORMS; do
17
+for platform in ${DOCKER_CROSSPLATFORMS}; do
18 18
 	(
19 19
 		export KEEPDEST=1
20
-		export DEST="$DEST/$platform" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION
20
+		export DEST="${DEST}/${platform}" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION
21 21
 		export GOOS=${platform%/*}
22 22
 		export GOARCH=${platform##*/}
23 23
 
24
-		echo "Cross building: $DEST"
25
-		mkdir -p "$DEST"
26
-		ABS_DEST="$(cd "$DEST" && pwd -P)"
24
+		echo "Cross building: ${DEST}"
25
+		mkdir -p "${DEST}"
26
+		ABS_DEST="$(cd "${DEST}" && pwd -P)"
27 27
 		source "${MAKEDIR}/binary-daemon"
28 28
 
29 29
 		source "${MAKEDIR}/cross-platform-dependent"
... ...
@@ -1,6 +1,6 @@
1 1
 #!/usr/bin/env bash
2 2
 set -e
3 3
 
4
-if [ $platform == "windows/amd64" ]; then
4
+if [ ${platform} == "windows/amd64" ]; then
5 5
 	source "${MAKEDIR}/containerutility"
6 6
 fi
... ...
@@ -35,10 +35,10 @@ fi
35 35
 
36 36
 args="--debug \
37 37
 	--host tcp://0.0.0.0:${listen_port} --host unix:///var/run/docker.sock \
38
-	--storage-driver "$DOCKER_GRAPHDRIVER" \
39
-	--userland-proxy="$DOCKER_USERLANDPROXY" \
38
+	--storage-driver "${DOCKER_GRAPHDRIVER}" \
39
+	--userland-proxy="${DOCKER_USERLANDPROXY}" \
40 40
 	$storage_params \
41 41
 	$extra_params"
42 42
 
43
-echo dockerd $args
44
-exec dockerd $args
43
+echo dockerd ${args}
44
+exec dockerd ${args}
... ...
@@ -8,7 +8,7 @@ source hack/make/.integration-test-helpers
8 8
 	bundle .integration-daemon-start
9 9
 	bundle .integration-daemon-setup
10 10
 
11
-	local testexit=0
11
+	testexit=0
12 12
 	( repeat run_test_integration ) || testexit=$?
13 13
 
14 14
 	# Always run cleanup, even if the subshell fails
... ...
@@ -16,6 +16,6 @@ source hack/make/.integration-test-helpers
16 16
 	cleanup_test_suite_binaries
17 17
 	error_on_leaked_containerd_shims
18 18
 
19
-	exit $testexit
19
+	exit ${testexit}
20 20
 
21 21
 ) 2>&1 | tee -a "$DEST/test.log"
... ...
@@ -24,7 +24,7 @@ for pkg in $pkg_list; do
24 24
         -cover \
25 25
         -coverprofile=profile.out \
26 26
         -covermode=atomic \
27
-        $TESTFLAGS \
27
+        ${TESTFLAGS} \
28 28
         "${pkg}"
29 29
 
30 30
     if test -f profile.out; then
... ...
@@ -4,5 +4,5 @@
4 4
 
5 5
 export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6 6
 
7
-. $SCRIPTDIR/default
8
-. $SCRIPTDIR/vendor
7
+. ${SCRIPTDIR}/default
8
+. ${SCRIPTDIR}/vendor
... ...
@@ -21,7 +21,7 @@ check_dco() {
21 21
 	grep -qE "$dcoRegex"
22 22
 }
23 23
 
24
-if [ $adds -eq 0 -a $dels -eq 0 ]; then
24
+if [ ${adds} -eq 0 -a ${dels} -eq 0 ]; then
25 25
 	echo '0 adds, 0 deletions; nothing to validate! :)'
26 26
 else
27 27
 	commits=( $(validate_log --format='format:%H%n') )
... ...
@@ -4,14 +4,14 @@
4 4
 
5 5
 export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6 6
 
7
-. $SCRIPTDIR/dco
8
-. $SCRIPTDIR/default-seccomp
9
-. $SCRIPTDIR/gometalinter
10
-. $SCRIPTDIR/pkg-imports
11
-. $SCRIPTDIR/swagger
12
-. $SCRIPTDIR/swagger-gen
13
-. $SCRIPTDIR/test-imports
14
-. $SCRIPTDIR/toml
15
-. $SCRIPTDIR/changelog-well-formed
16
-. $SCRIPTDIR/changelog-date-descending
17
-. $SCRIPTDIR/deprecate-integration-cli
7
+. ${SCRIPTDIR}/dco
8
+. ${SCRIPTDIR}/default-seccomp
9
+. ${SCRIPTDIR}/gometalinter
10
+. ${SCRIPTDIR}/pkg-imports
11
+. ${SCRIPTDIR}/swagger
12
+. ${SCRIPTDIR}/swagger-gen
13
+. ${SCRIPTDIR}/test-imports
14
+. ${SCRIPTDIR}/toml
15
+. ${SCRIPTDIR}/changelog-well-formed
16
+. ${SCRIPTDIR}/changelog-date-descending
17
+. ${SCRIPTDIR}/deprecate-integration-cli
... ...
@@ -10,4 +10,4 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10 10
 
11 11
 gometalinter \
12 12
 	${GOMETALINTER_OPTS} \
13
-	--config $SCRIPTDIR/gometalinter.json ./...
13
+	--config ${SCRIPTDIR}/gometalinter.json ./...