]> granicus.if.org Git - zfs/commitdiff
Correct shellcheck errors
authorGiuseppe Di Natale <dinatale2@users.noreply.github.com>
Mon, 18 Sep 2017 21:23:09 +0000 (14:23 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 18 Sep 2017 21:23:09 +0000 (14:23 -0700)
The ZFS buildbot moved to using Ubuntu 17.04 for the
STYLE builder which has a newer version of shellcheck.
Correct the new issues it discovers.

Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Closes #6647

scripts/zfs-helpers.sh
scripts/zfs.sh
scripts/zimport.sh

index 3fbe64a52703e1b91271bdd98222ead2321d4dd4..56d33b9c817f1f2d222d8ff21278be4c659b8876 100755 (executable)
@@ -88,11 +88,11 @@ while getopts 'hdirv' OPTION; do
        esac
 done
 
-if [ "$INSTALL" = "yes" -a "$REMOVE" = "yes" ]; then
+if [ "$INSTALL" = "yes" ] && [ "$REMOVE" = "yes" ]; then
        fail "Specify -i or -r but not both"
 fi
 
-if [ "$INSTALL" = "no" -a "$REMOVE" = "no" ]; then
+if [ "$INSTALL" = "no" ] && [ "$REMOVE" = "no" ]; then
        fail "Either -i or -r must be specified"
 fi
 
@@ -115,8 +115,8 @@ if [ "$VERBOSE" = "yes" ]; then
 fi
 
 install() {
-       local src=$1
-       local dst=$2
+       src=$1
+       dst=$2
 
        if [ -h "$dst" ]; then
                echo "Symlink exists: $dst"
@@ -136,7 +136,7 @@ install() {
 }
 
 remove() {
-       local dst=$1
+       dst=$1
 
        if [ -h "$dst" ]; then
                msg "rm $dst"
index 7dbb51a170945463a2d6a8f17d1496ced7a737b7..8ece6ef5f6038e1e70ddb87316fb13f0147c9494 100755 (executable)
@@ -72,8 +72,8 @@ kill_zed() {
 }
 
 check_modules() {
-       local LOADED_MODULES=""
-       local MISSING_MODULES=""
+       LOADED_MODULES=""
+       MISSING_MODULES=""
 
        for KMOD in $KMOD_SPL $KMOD_SPLAT $KMOD_ZAVL $KMOD_ZNVPAIR \
            $KMOD_ZUNICODE $KMOD_ZCOMMON $KMOD_ICP $KMOD_ZFS; do
@@ -104,7 +104,7 @@ check_modules() {
 }
 
 load_module() {
-       local KMOD=$1
+       KMOD=$1
 
        FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}')
        VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}')
@@ -146,7 +146,7 @@ load_modules() {
 }
 
 unload_module() {
-       local KMOD=$1
+       KMOD=$1
 
        NAME=$(basename "$KMOD" .ko)
        FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}')
@@ -188,8 +188,8 @@ unload_modules() {
 }
 
 stack_clear() {
-       local STACK_MAX_SIZE=/sys/kernel/debug/tracing/stack_max_size
-       local STACK_TRACER_ENABLED=/proc/sys/kernel/stack_tracer_enabled
+       STACK_MAX_SIZE=/sys/kernel/debug/tracing/stack_max_size
+       STACK_TRACER_ENABLED=/proc/sys/kernel/stack_tracer_enabled
 
        if [ -e "$STACK_MAX_SIZE" ]; then
                echo 1 >"$STACK_TRACER_ENABLED"
@@ -198,9 +198,9 @@ stack_clear() {
 }
 
 stack_check() {
-       local STACK_MAX_SIZE=/sys/kernel/debug/tracing/stack_max_size
-       local STACK_TRACE=/sys/kernel/debug/tracing/stack_trace
-       local STACK_LIMIT=7600
+       STACK_MAX_SIZE=/sys/kernel/debug/tracing/stack_max_size
+       STACK_TRACE=/sys/kernel/debug/tracing/stack_trace
+       STACK_LIMIT=7600
 
        if [ -e "$STACK_MAX_SIZE" ]; then
                STACK_SIZE=$(cat "$STACK_MAX_SIZE")
index c72a4a4e4e52fbc97230837ef22741e5b5ebf095..36d4e66965901d642b5426de3db53f02819e87da 100755 (executable)
@@ -286,7 +286,7 @@ pool_create() {
        src_set_vars "$1"
 
        if [ "$POOL_TAG" != "installed" ]; then
-               cd "$POOL_DIR_SRC"
+               cd "$POOL_DIR_SRC" || fail "Failed 'cd $POOL_DIR_SRC'"
        fi
 
        $ZFS_SH zfs="spa_config_path=$POOL_DIR_PRISTINE" || \
@@ -406,7 +406,7 @@ for TAG in $SRC_TAGS; do
        elif  [ "$SPL_TAG" = "installed" ]; then
                skip_nonewline
        else
-               cd "$SRC_DIR"
+               cd "$SRC_DIR" || fail "Failed 'cd $SRC_DIR'"
 
                if [ ! -d "$SRC_DIR_SPL" ]; then
                        mkdir -p "$SRC_DIR_SPL"
@@ -443,7 +443,7 @@ for TAG in $SRC_TAGS; do
        elif  [ "$ZFS_TAG" = "installed" ]; then
                skip_nonewline
        else
-               cd "$SRC_DIR"
+               cd "$SRC_DIR" || fail "Failed 'cd $SRC_DIR'"
 
                if [ ! -d "$SRC_DIR_ZFS" ]; then
                        mkdir -p "$SRC_DIR_ZFS"
@@ -477,7 +477,7 @@ for TAG in $SRC_TAGS; do
        elif  [ "$SPL_TAG" = "installed" ]; then
                skip_nonewline
        else
-               cd "$SPL_DIR"
+               cd "$SPL_DIR" || fail "Failed 'cd $SPL_DIR'"
                make distclean &>/dev/null
                ./autogen.sh >>"$CONFIG_LOG" 2>&1 || \
                    fail "Failed SPL 'autogen.sh'"
@@ -502,7 +502,7 @@ for TAG in $SRC_TAGS; do
        elif  [ "$ZFS_TAG" = "installed" ]; then
                skip_nonewline
        else
-               cd "$ZFS_DIR"
+               cd "$ZFS_DIR" || fail "Failed 'cd $ZFS_DIR'"
                make distclean &>/dev/null
                ./autogen.sh >>"$CONFIG_LOG" 2>&1 || \
                    fail "Failed ZFS 'autogen.sh'"
@@ -545,16 +545,16 @@ for TAG in $POOL_TAGS; do
        fi
 
        # Verify 'zpool import' works for all listed source versions.
-       for TAG in $SRC_TAGS; do
+       for SRC_TAG in $SRC_TAGS; do
 
                if [ $SKIP -eq 1 ]; then
                        skip_nonewline
                        continue
                fi
 
-               src_set_vars "$TAG"
-               if [ "$TAG" != "installed" ]; then
-                       cd "$ZFS_DIR"
+               src_set_vars "$SRC_TAG"
+               if [ "$SRC_TAG" != "installed" ]; then
+                       cd "$ZFS_DIR" || fail "Failed 'cd $ZFS_DIR'"
                fi
                $ZFS_SH zfs="spa_config_path=$POOL_DIR_COPY"