Skip to content

Commit

Permalink
Correct shellcheck make recipe
Browse files Browse the repository at this point in the history
Consolidated the shellcheck call in the
make recipe down to a single call of
shellcheck. Corrected script errors that
have been skipped. Corrected script errors
that have been introduced because make
wasn't reporting any errors from shellcheck.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Giuseppe Di Natale <[email protected]>
Closes openzfs#5976
  • Loading branch information
dinatale2 authored and behlendorf committed Apr 7, 2017
1 parent bbfd635 commit 7469863
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
12 changes: 4 additions & 8 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,13 @@ cstyle:

shellcheck:
@if type shellcheck > /dev/null 2>&1; then \
shellcheck --exclude=SC1090 --format gcc scripts/paxcheck.sh \
shellcheck --exclude=SC1090 --format=gcc scripts/paxcheck.sh \
scripts/zloop.sh \
scripts/zfs-tests.sh \
scripts/zfs.sh \
scripts/commitcheck.sh; \
(find cmd/zed/zed.d/*.sh -type f) | \
grep -v 'zfs-script-config' | \
while read file; do \
shellcheck --exclude=SC1090 --format gcc "$$file"; \
done; \
fi
scripts/commitcheck.sh \
$$(find cmd/zed/zed.d/*.sh -type f); \
fi

lint: cppcheck paxcheck

Expand Down
36 changes: 18 additions & 18 deletions scripts/zfs-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ cleanup() {
done

# Preserve in-tree symlinks to aid debugging.
if [ -z "${INTREE}" -a -d "$STF_PATH" ]; then
if [ -z "${INTREE}" ] && [ -d "$STF_PATH" ]; then
rm -Rf "$STF_PATH"
fi
}
Expand All @@ -89,7 +89,7 @@ trap cleanup EXIT
#
cleanup_all() {
local TEST_POOLS
TEST_POOLS=$(sudo $ZPOOL list -H -o name | grep testpool)
TEST_POOLS=$(sudo "$ZPOOL" list -H -o name | grep testpool)
local TEST_LOOPBACKS
TEST_LOOPBACKS=$(sudo "${LOSETUP}" -a|grep file-vdev|cut -f1 -d:)
local TEST_FILES
Expand All @@ -99,7 +99,7 @@ cleanup_all() {
msg "--- Cleanup ---"
msg "Removing pool(s): $(echo "${TEST_POOLS}" | tr '\n' ' ')"
for TEST_POOL in $TEST_POOLS; do
sudo $ZPOOL destroy "${TEST_POOL}"
sudo "$ZPOOL" destroy "${TEST_POOL}"
done

msg "Removing dm(s): $(sudo "${DMSETUP}" ls |
Expand Down Expand Up @@ -159,20 +159,20 @@ create_links() {
local dir_list="$1"
local file_list="$2"

[ -n $STF_PATH ] || fail "STF_PATH wasn't correctly set"
[ -n "$STF_PATH" ] || fail "STF_PATH wasn't correctly set"

for i in $file_list; do
for j in $dir_list; do
[ ! -e "$STF_PATH/$i" ] || continue

if [ ! -d "$j/$i" -a -e "$j/$i" ]; then
ln -s $j/$i $STF_PATH/$i || \
if [ ! -d "$j/$i" ] && [ -e "$j/$i" ]; then
ln -s "$j/$i" "$STF_PATH/$i" || \
fail "Couldn't link $i"
break
fi
done

[ ! -e $STF_PATH/$i ] && STF_MISSING_BIN="$STF_MISSING_BIN$i "
[ ! -e "$STF_PATH/$i" ] && STF_MISSING_BIN="$STF_MISSING_BIN$i "
done
}

Expand All @@ -182,7 +182,7 @@ create_links() {
# convenience, otherwise a temporary directory is used.
#
constrain_path() {
. $STF_SUITE/include/commands.cfg
. "$STF_SUITE/include/commands.cfg"

if [ -n "${INTREE}" ]; then
STF_PATH="$BUILDDIR/bin"
Expand All @@ -195,7 +195,7 @@ constrain_path() {
fi

STF_MISSING_BIN=""
chmod 755 $STF_PATH || fail "Couldn't chmod $STF_PATH"
chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH"

# Standard system utilities
create_links "/bin /usr/bin /sbin /usr/sbin" "$SYSTEM_FILES"
Expand All @@ -219,12 +219,12 @@ constrain_path() {
fi

# Exceptions
ln -fs $STF_PATH/awk $STF_PATH/nawk
ln -fs /sbin/mkfs.ext2 $STF_PATH/newfs
ln -fs $STF_PATH/gzip $STF_PATH/compress
ln -fs $STF_PATH/gunzip $STF_PATH/uncompress
ln -fs $STF_PATH/exportfs $STF_PATH/share
ln -fs $STF_PATH/exportfs $STF_PATH/unshare
ln -fs "$STF_PATH/awk" "$STF_PATH/nawk"
ln -fs /sbin/mkfs.ext2 "$STF_PATH/newfs"
ln -fs "$STF_PATH/gzip" "$STF_PATH/compress"
ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress"
ln -fs "$STF_PATH/exportfs" "$STF_PATH/share"
ln -fs "$STF_PATH/exportfs" "$STF_PATH/unshare"
}

#
Expand Down Expand Up @@ -396,7 +396,7 @@ constrain_path
#
# Check if ksh exists
#
[ -e $STF_PATH/ksh ] || fail "This test suite requires ksh."
[ -e "$STF_PATH/ksh" ] || fail "This test suite requires ksh."

#
# Verify the ZFS module stack if loaded.
Expand All @@ -414,15 +414,15 @@ fi
# By default preserve any existing pools
#
if [ -z "${KEEP}" ]; then
KEEP=$(sudo $ZPOOL list -H -o name)
KEEP=$(sudo "$ZPOOL" list -H -o name)
if [ -z "${KEEP}" ]; then
KEEP="rpool"
fi
fi

__ZFS_POOL_EXCLUDE="$(echo $KEEP | sed ':a;N;s/\n/ /g;ba')"

. $STF_SUITE/include/default.cfg
. "$STF_SUITE/include/default.cfg"

msg
msg "--- Configuration ---"
Expand Down

0 comments on commit 7469863

Please sign in to comment.