Skip to content

Commit b3cb0d7

Browse files
committed
PR comments - added quoting and set -e so that things will fail when they fail
1 parent 819b0da commit b3cb0d7

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

tests/flow/Install_RedisGears.sh

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/bin/bash
22

3+
set -e
4+
35
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
46
ROOT=$(cd $HERE/../.. && pwd)
57
READIES=$ROOT/opt/readies
68
. $READIES/shibumi/defs
79

8-
if [[ $1 == --help || $1 == help || $HELP == 1 ]]; then
10+
if [[ "$1" == "--help" || "$1" == "help" || "$HELP" == "1" ]]; then
911
cat <<-END
1012
Obtain RedisGears module binaries
1113
1214
Install_RedisGears.sh [--help|help]
13-
15+
1416
Argument variables:
1517
GEARS_OSNICK=nick Get binaries for give osnick
1618
GEARS_PATH=dir Get binaries from given Gears repo
@@ -22,47 +24,47 @@ if [[ $1 == --help || $1 == help || $HELP == 1 ]]; then
2224
fi
2325

2426
OP=""
25-
[[ $NOP == 1 ]] && OP=echo
27+
[[ "$NOP" == "1" ]] && OP=echo
2628

27-
os=$($READIES/bin/platform --os)
28-
arch=$($READIES/bin/platform --arch)
29+
os="$($READIES/bin/platform --os)"
30+
arch="$($READIES/bin/platform --arch)"
2931

30-
if [[ ! -z $GEARS_PATH ]]; then
31-
platform=$($READIES/bin/platform -t)
32+
if [[ ! -z "$GEARS_PATH" ]]; then
33+
platform="$($READIES/bin/platform -t)"
3234
else
33-
if [[ $os != linux || $arch != x64 ]]; then
35+
if [[ "$os" != "linux" || "$arch" != "x64" ]]; then
3436
eprint "Cannot match binary artifacts - build RedisGears and set GEARS_PATH"
3537
exit 1
3638
fi
3739

38-
dist=$($READIES/bin/platform --dist)
39-
nick=$($READIES/bin/platform --osnick)
40+
dist="$($READIES/bin/platform --dist)"
41+
nick="$($READIES/bin/platform --osnick)"
4042

41-
if [[ $dist == ubuntu ]]; then
42-
if [[ $nick != bionic && $nick != xenial && $nick != trusty ]]; then
43-
nick=bionic
43+
if [[ $dist == "ubuntu" ]]; then
44+
if [[ $nick != "bionic" && $nick != "xenial" && $nick != "trusty" ]]; then
45+
nick="bionic"
4446
fi
4547
elif [[ $dist == debian ]]; then
4648
nick=bionic
4749
elif [[ $dist == centos || $dist == redhat || $dist == fedora ]]; then
4850
nick=centos7
49-
elif [[ ! -z $GEARS_OSNICK ]]; then
50-
nick="$GEARS_OSNICK"
51+
elif [[ ! -z "$GEARS_OSNICK" ]]; then
52+
nick=$GEARS_OSNICK
5153
else
5254
eprint "Cannot match binary artifacts - build RedisGears and set GEARS_PATH"
5355
exit 1
5456
fi
5557
platform="${os}-${nick}-${arch}"
5658
fi
5759

58-
GEARS_S3_URL=http://redismodules.s3.amazonaws.com/redisgears/snapshots
59-
GEARS_MOD=redisgears.${platform}.master.zip
60-
GEARS_DEPS=redisgears-python.${platform}.master.tgz
60+
GEARS_S3_URL="http://redismodules.s3.amazonaws.com/redisgears/snapshots"
61+
GEARS_MOD="redisgears.${platform}.master.zip"
62+
GEARS_DEPS="redisgears-python.${platform}.master.tgz"
6163

62-
FINAL_WORK_DIR=$ROOT/bin/$($READIES/bin/platform -t)/RedisGears
64+
FINAL_WORK_DIR="$ROOT/bin/$($READIES/bin/platform -t)/RedisGears"
6365

6466
if [[ -d $FINAL_WORK_DIR && -f $FINAL_WORK_DIR/redisgears.so ]]; then
65-
echo "RedisGears is in $FINAL_WORK_DIR"
67+
echo "RedisGears is in ${FINAL_WORK_DIR}"
6668
exit 0
6769
fi
6870

@@ -72,20 +74,20 @@ WORK_DIR=$(mktemp -d ${FINAL_WORK_DIR}.XXXXXX)
7274
$OP mkdir -p $WORK_DIR
7375

7476
if [[ -z $GEARS_PATH ]]; then
75-
F_GEARS_MOD=$WORK_DIR/$GEARS_MOD
77+
F_GEARS_MOD="$WORK_DIR/$GEARS_MOD"
7678
if [[ ! -f $F_GEARS_MOD ]]; then
7779
echo "Download RedisGears ..."
7880
$OP wget -q -P $WORK_DIR $GEARS_S3_URL/$GEARS_MOD
7981
fi
8082

81-
F_GEARS_DEPS=$WORK_DIR/$GEARS_DEPS
83+
F_GEARS_DEPS="$WORK_DIR/$GEARS_DEPS"
8284
if [[ ! -f $F_GEARS_DEPS ]]; then
8385
echo "Download RedisGears deps ..."
8486
$OP wget -q -P $WORK_DIR $GEARS_S3_URL/$GEARS_DEPS
8587
fi
8688
else
87-
F_GEARS_MOD=$GEARS_PATH/artifacts/snapshot/$GEARS_MOD
88-
F_GEARS_DEPS=$GEARS_PATH/artifacts/snapshot/$GEARS_DEPS
89+
F_GEARS_MOD="${GEARS_PATH}/artifacts/snapshot/${GEARS_MOD}"
90+
F_GEARS_DEPS="${GEARS_PATH}/artifacts/snapshot/${GEARS_DEPS}"
8991
[[ ! -f $F_GEARS_MOD ]] && { eprint "$F_GEARS_MOD is missing"; exit 1; }
9092
[[ ! -f $F_GEARS_DEPS ]] && { eprint "$F_GEARS_DEPS is missing"; exit 1; }
9193
fi

0 commit comments

Comments
 (0)