Skip to content

Commit 297b30d

Browse files
committed
Bash scripts; use double brackets, fix bare variables, add quotes
These scripts explicitly use Bash, so we should be able to use `[[` instead of `[` (which seems to be recommended). Also added curly brackets to some bare variables, and quoted some paths. This makes my IDE a bit more silent :-) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent d147fe0 commit 297b30d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+143
-144
lines changed

hack/dind

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set -e
1313
# apparmor sucks and Docker needs to know that it's in a container (c) @tianon
1414
export container=docker
1515

16-
if [ -d /sys/kernel/security ] && ! mountpoint -q /sys/kernel/security; then
16+
if [[ -d /sys/kernel/security ]] && ! mountpoint -q /sys/kernel/security; then
1717
mount -t securityfs none /sys/kernel/security || {
1818
echo >&2 'Could not mount /sys/kernel/security.'
1919
echo >&2 'AppArmor detection and --privileged mode might break.'
@@ -25,7 +25,7 @@ if ! mountpoint -q /tmp; then
2525
mount -t tmpfs none /tmp
2626
fi
2727

28-
if [ $# -gt 0 ]; then
28+
if [[ $# -gt 0 ]]; then
2929
exec "$@"
3030
fi
3131

hack/dockerfile/install/containerd.installer

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ install_containerd() {
2828
make
2929
)
3030

31-
mkdir -p ${PREFIX}
31+
mkdir -p "${PREFIX}"
3232

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"
3636
}

hack/dockerfile/install/dockercli.installer

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ install_dockercli() {
88

99
arch=$(uname -m)
1010
# No official release of these platforms
11-
if [[ "$arch" != "x86_64" ]] && [[ "$arch" != "s390x" ]]; then
11+
if [ "$arch" != "x86_64" ] && [ "$arch" != "s390x" ]; then
1212
build_dockercli
1313
return
1414
fi
1515

1616
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
1918
mkdir -p ${PREFIX}
2019
mv docker/docker ${PREFIX}/
2120
rmdir docker
@@ -27,5 +26,5 @@ build_dockercli() {
2726
git checkout -q "v$DOCKERCLI_VERSION"
2827
mkdir -p "$GOPATH/src/github.com/docker"
2928
mv components/cli "$GOPATH/src/github.com/docker/cli"
30-
go build -buildmode=pie -o ${PREFIX}/docker github.com/docker/cli/cmd/docker
29+
go build -buildmode=pie -o "${PREFIX}/docker" "github.com/docker/cli/cmd/docker"
3130
}

hack/dockerfile/install/gometalinter.installer

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ install_gometalinter() {
77
go get -d github.com/alecthomas/gometalinter
88
cd "$GOPATH/src/github.com/alecthomas/gometalinter"
99
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
1212
}

hack/dockerfile/install/install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TMP_GOPATH=${TMP_GOPATH:-""}
99

1010
: ${PREFIX:="/usr/local/bin"}
1111

12-
if [ -z "$TMP_GOPATH" ]; then
12+
if [[ -z "$TMP_GOPATH" ]]; then
1313
export GOPATH="$(mktemp -d)"
1414
RM_GOPATH=1
1515
else
@@ -21,10 +21,10 @@ dir="$(dirname $0)"
2121
bin=$1
2222
shift
2323

24-
if [ ! -f "${dir}/${bin}.installer" ]; then
24+
if [[ ! -f "${dir}/${bin}.installer" ]]; then
2525
echo "Could not find installer for \"$bin\""
2626
exit 1
2727
fi
2828

29-
. $dir/$bin.installer
30-
install_$bin "$@"
29+
. ${dir}/${bin}.installer
30+
install_${bin} "$@"

hack/dockerfile/install/proxy.installer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ _install_proxy() {
3232
git clone https://github.com/docker/libnetwork.git "$GOPATH/src/github.com/docker/libnetwork"
3333
cd "$GOPATH/src/github.com/docker/libnetwork"
3434
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
3636
}
3737

3838

hack/dockerfile/install/runc.installer

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ install_runc() {
2525
target="$1"
2626
fi
2727
make BUILDTAGS="$RUNC_BUILDTAGS" "$target"
28-
mkdir -p ${PREFIX}
29-
cp runc ${PREFIX}/runc
28+
mkdir -p "${PREFIX}"
29+
cp runc "${PREFIX}/runc"
3030
}

hack/dockerfile/install/tini.installer

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ install_tini() {
99
git checkout -q "$TINI_COMMIT"
1010
cmake .
1111
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"
1414
}

hack/dockerfile/install/tomlv.installer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ install_tomlv() {
88
echo "Install tomlv version $TOMLV_COMMIT"
99
git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml"
1010
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"
1212
}

hack/dockerfile/install/vndr.installer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ install_vndr() {
77
git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr"
88
cd "$GOPATH/src/github.com/LK4D4/vndr"
99
git checkout -q "$VNDR_COMMIT"
10-
go build -buildmode=pie -v -o ${PREFIX}/vndr .
10+
go build -buildmode=pie -v -o "${PREFIX}/vndr" .
1111
}

0 commit comments

Comments
 (0)