Skip to content

Commit 698716b

Browse files
committed
unpack-tarballs: fixed shellcheck issues
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 6fad303 commit 698716b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

build-scripts/unpack-tarballs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/bin/sh -x
22

3-
. $(dirname "$0")/functions
3+
. "$(dirname "$0")"/functions
44
. detect-environment
55
. compile-options
66

77
SOURCE_TARBALL="$BASEDIR/output/tarballs/cfengine-3.*.tar.gz"
8-
MASTERFILES_TARBALL=$(ls $BASEDIR/output/tarballs/cfengine-masterfiles*.tar.gz | grep -v 'pkg.tar.gz$')
8+
# shellcheck disable=SC2010
9+
# > Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.
10+
# TODO: CFE-4587
11+
MASTERFILES_TARBALL=$(ls "$BASEDIR"/output/tarballs/cfengine-masterfiles*.tar.gz | grep -v 'pkg.tar.gz$')
912

1013
# DELETE the git-checked-out directories, they are tainted with
1114
# ./configure artifacts anyway. The tarballs are unpacked and symlinked
@@ -23,17 +26,23 @@ if [ -e "$BASEDIR/core/" ] || [ -e "$BASEDIR/masterfiles/" ]; then
2326
exit 1
2427
fi
2528

26-
if [ x$PROJECT = xcommunity ]; then
29+
if [ "$PROJECT" = community ]; then
2730
sudo rm -rf "$BASEDIR/enterprise" "$BASEDIR/nova" "$BASEDIR/mission-portal"
2831
fi
2932

3033
# NATIVE TAR is being used on purpose, and *not* GNU TAR.
3134

3235
echo "UNPACKING SOURCE TARBALL AND SYMLINKING core"
33-
cd $BASEDIR
36+
cd "$BASEDIR"
37+
# shellcheck disable=SC2086
38+
# > Double quote to prevent globbing and word splitting.
39+
# We want globbing here
3440
gzip -dc $SOURCE_TARBALL | tar -xf -
3541
ln -s cfengine-3* core
3642

3743
echo "UNPACKING MASTERFILES TARBALL AND SYMLINKING masterfiles/"
44+
# shellcheck disable=SC2086
45+
# > Double quote to prevent globbing and word splitting.
46+
# We want globbing here
3847
gzip -dc $MASTERFILES_TARBALL | tar -xf -
3948
ln -s cfengine-masterfiles-* masterfiles

0 commit comments

Comments
 (0)