Skip to content

Commit a9824cd

Browse files
mvdanianlancetaylor
authored andcommitted
*.bash: always use the same string equality operator
POSIX Shell only supports = to compare variables inside '[' tests. But this is Bash, where == is an alias for =. In practice they're the same, but the current form is inconsisnent and breaks POSIX for no good reason. Change-Id: I38fa7a5a90658dc51acc2acd143049e510424ed8 Reviewed-on: https://go-review.googlesource.com/38031 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent 723ba18 commit a9824cd

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

doc/articles/wiki/test.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trap cleanup 0 INT
2020
rm -f get.bin final-test.bin a.out
2121

2222
# If called with -all, check that all code snippets compile.
23-
if [ "$1" == "-all" ]; then
23+
if [ "$1" = "-all" ]; then
2424
for fn in *.go; do
2525
go build -o a.out $fn
2626
done

lib/time/update.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ zip -0 -r ../../zoneinfo.zip *
4242
cd ../..
4343

4444
echo
45-
if [ "$1" == "-work" ]; then
45+
if [ "$1" = "-work" ]; then
4646
echo Left workspace behind in work/.
4747
else
4848
rm -rf work

misc/cgo/fortran/test.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ FC=$1
1212
goos=$(go env GOOS)
1313

1414
libext="so"
15-
if [ "$goos" == "darwin" ]; then
15+
if [ "$goos" = "darwin" ]; then
1616
libext="dylib"
1717
fi
1818

misc/cgo/testcshared/test.bash

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fi
2727
# Directory where cgo headers and outputs will be installed.
2828
# The installation directory format varies depending on the platform.
2929
installdir=pkg/${goos}_${goarch}_testcshared_shared
30-
if [ "${goos}" == "darwin" ]; then
30+
if [ "${goos}" = "darwin" ]; then
3131
installdir=pkg/${goos}_${goarch}_testcshared
3232
fi
3333

@@ -40,13 +40,13 @@ function cleanup() {
4040
rm -f testp testp2 testp3 testp4 testp5
4141
rm -rf pkg "${goroot}/${installdir}"
4242

43-
if [ "$goos" == "android" ]; then
43+
if [ "$goos" = "android" ]; then
4444
adb shell rm -rf "$androidpath"
4545
fi
4646
}
4747
trap cleanup EXIT
4848

49-
if [ "$goos" == "android" ]; then
49+
if [ "$goos" = "android" ]; then
5050
adb shell mkdir -p "$androidpath"
5151
fi
5252

@@ -69,7 +69,7 @@ function run() {
6969

7070
function binpush() {
7171
bin=${1}
72-
if [ "$goos" == "android" ]; then
72+
if [ "$goos" = "android" ]; then
7373
adb push "$bin" "${androidpath}/${bin}" 2>/dev/null
7474
fi
7575
}
@@ -79,7 +79,7 @@ rm -rf pkg
7979
suffix="-installsuffix testcshared"
8080

8181
libext="so"
82-
if [ "$goos" == "darwin" ]; then
82+
if [ "$goos" = "darwin" ]; then
8383
libext="dylib"
8484
fi
8585

@@ -89,15 +89,15 @@ GOPATH=$(pwd) go install -buildmode=c-shared $suffix libgo
8989
GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo.$libext src/libgo/libgo.go
9090
binpush libgo.$libext
9191

92-
if [ "$goos" == "linux" ] || [ "$goos" == "android" ] ; then
92+
if [ "$goos" = "linux" ] || [ "$goos" = "android" ] ; then
9393
if readelf -d libgo.$libext | grep TEXTREL >/dev/null; then
9494
echo "libgo.$libext has TEXTREL set"
9595
exit 1
9696
fi
9797
fi
9898

9999
GOGCCFLAGS=$(go env GOGCCFLAGS)
100-
if [ "$goos" == "android" ]; then
100+
if [ "$goos" = "android" ]; then
101101
GOGCCFLAGS="${GOGCCFLAGS} -pie"
102102
fi
103103

@@ -127,7 +127,7 @@ fi
127127
GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo2.$libext libgo2
128128
binpush libgo2.$libext
129129
linkflags="-Wl,--no-as-needed"
130-
if [ "$goos" == "darwin" ]; then
130+
if [ "$goos" = "darwin" ]; then
131131
linkflags=""
132132
fi
133133
$(go env CC) ${GOGCCFLAGS} -o testp2 main2.c $linkflags libgo2.$libext
@@ -139,7 +139,7 @@ if [ "$output" != "PASS" ]; then
139139
fi
140140

141141
# test3: tests main.main is exported on android.
142-
if [ "$goos" == "android" ]; then
142+
if [ "$goos" = "android" ]; then
143143
$(go env CC) ${GOGCCFLAGS} -o testp3 main3.c -ldl
144144
binpush testp3
145145
output=$(run ./testp ./libgo.so)

misc/cgo/testsanitizers/test.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ testmsanshared() {
7272
goos=$(go env GOOS)
7373
suffix="-installsuffix testsanitizers"
7474
libext="so"
75-
if [ "$goos" == "darwin" ]; then
75+
if [ "$goos" = "darwin" ]; then
7676
libext="dylib"
7777
fi
7878
go build -msan -buildmode=c-shared $suffix -o ${TMPDIR}/libmsanshared.$libext msan_shared.go
@@ -135,7 +135,7 @@ testtsanshared() {
135135
goos=$(go env GOOS)
136136
suffix="-installsuffix tsan"
137137
libext="so"
138-
if [ "$goos" == "darwin" ]; then
138+
if [ "$goos" = "darwin" ]; then
139139
libext="dylib"
140140
fi
141141
go build -buildmode=c-shared $suffix -o ${TMPDIR}/libtsanshared.$libext tsan_shared.go

src/iostest.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ if [ "$GOARCH" != "arm" ] && [ "$GOARCH" != "arm64" ]; then
2424
echo "iostest.bash requires GOARCH=arm or GOARCH=arm64, got GOARCH=$GOARCH" 1>&2
2525
exit 1
2626
fi
27-
if [ "$GOARCH" == "arm" ]; then
27+
if [ "$GOARCH" = "arm" ]; then
2828
export GOARM=7
2929
fi
3030

31-
if [ "$1" == "-restart" ]; then
31+
if [ "$1" = "-restart" ]; then
3232
# Reboot to make sure previous runs do not interfere with the current run.
3333
# It is reasonably easy for a bad program leave an iOS device in an
3434
# almost unusable state.
@@ -60,7 +60,7 @@ GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build \
6060
-o ../bin/go_darwin_${GOARCH}_exec \
6161
../misc/ios/go_darwin_arm_exec.go
6262

63-
if [ "$GOIOS_DEV_ID" == "" ]; then
63+
if [ "$GOIOS_DEV_ID" = "" ]; then
6464
echo "detecting iOS development identity"
6565
eval $(GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go run ../misc/ios/detect.go)
6666
fi

src/make.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ done
107107
# Test for debian/kFreeBSD.
108108
# cmd/dist will detect kFreeBSD as freebsd/$GOARCH, but we need to
109109
# disable cgo manually.
110-
if [ "$(uname -s)" == "GNU/kFreeBSD" ]; then
110+
if [ "$(uname -s)" = "GNU/kFreeBSD" ]; then
111111
export CGO_ENABLED=0
112112
fi
113113

@@ -125,7 +125,7 @@ if [ ! -x "$GOROOT_BOOTSTRAP/bin/go" ]; then
125125
echo "Set \$GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4." >&2
126126
exit 1
127127
fi
128-
if [ "$GOROOT_BOOTSTRAP" == "$GOROOT" ]; then
128+
if [ "$GOROOT_BOOTSTRAP" = "$GOROOT" ]; then
129129
echo "ERROR: \$GOROOT_BOOTSTRAP must not be set to \$GOROOT" >&2
130130
echo "Set \$GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4." >&2
131131
exit 1

src/run.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ ulimit -c 0
3636
# This is a system misconfiguration and should be fixed on the
3737
# broken system, not "fixed" by ignoring the failure here.
3838
# See longer discussion on golang.org/issue/7381.
39-
[ "$(ulimit -H -n)" == "unlimited" ] || ulimit -S -n $(ulimit -H -n)
40-
[ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d)
39+
[ "$(ulimit -H -n)" = "unlimited" ] || ulimit -S -n $(ulimit -H -n)
40+
[ "$(ulimit -H -d)" = "unlimited" ] || ulimit -S -d $(ulimit -H -d)
4141

4242
# Thread count limit on NetBSD 7.
4343
if ulimit -T &> /dev/null; then
44-
[ "$(ulimit -H -T)" == "unlimited" ] || ulimit -S -T $(ulimit -H -T)
44+
[ "$(ulimit -H -T)" = "unlimited" ] || ulimit -S -T $(ulimit -H -T)
4545
fi
4646

4747
exec go tool dist test -rebuild "$@"

0 commit comments

Comments
 (0)