ctdb-doc: Fix shellcheck warning in example NFS ganesha call-out
authorMartin Schwenke <martin@meltin.net>
Wed, 22 Feb 2017 03:44:09 +0000 (14:44 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 24 Feb 2017 06:47:11 +0000 (07:47 +0100)
In ctdb/doc/examples/nfs-ganesha-callout line 216:
for node in `ls ${GANSTATEDIR}`; do
            ^-- SC2045: Iterating over ls output is fragile. Use globs.
            ^-- SC2006: Use $(..) instead of legacy `..`.
                ^-- SC2086: Double quote to prevent globbing and word splitting.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/doc/examples/nfs-ganesha-callout

index ac966991a178cf69ea7a7fb86b0e706dfdbf7ce8..283f20482aeec66672f16f9d6ab563d4c52e3ed1 100755 (executable)
@@ -213,12 +213,18 @@ create_ganesha_recdirs ()
 
                mkdir -p "$GANSTATEDIR"
                check_ln "$NODESTATEDIR" "$NODESTATELN"
-               for node in `ls ${GANSTATEDIR}`; do
-                       if [ "${node}" != "${host}" ]; then
-                               check_ln "${GANSTATEDIR}/${node}/ganesha" \
-                                        "${NODESTATEDIR}/ganesha/${node}"
-                               check_ln "${GANSTATEDIR}/${node}/statd" \
-                                        "${NODESTATEDIR}/statd/${node}"
+               for _dir in "${GANSTATEDIR}/"* ; do
+                       # Handle no directories case
+                       if [ ! -d "$_dir" ] ; then
+                               break
+                       fi
+
+                       _node="${_dir##*/}" # basename
+                       if [ "${_node}" != "${host}" ]; then
+                               check_ln "${GANSTATEDIR}/${_node}/ganesha" \
+                                        "${NODESTATEDIR}/ganesha/${_node}"
+                               check_ln "${GANSTATEDIR}/${_node}/statd" \
+                                        "${NODESTATEDIR}/statd/${_node}"
                        fi
                done
                ;;