ctdb-scripts: Avoid shellcheck warning SC2059 ($ in printf format)
authorMartin Schwenke <martin@meltin.net>
Thu, 14 Jul 2016 02:08:04 +0000 (12:08 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 21 Jul 2016 00:24:27 +0000 (02:24 +0200)
SC2059: Don't use variables in the printf format string.
        Use printf "..%s.." "$foo".

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tools/ctdb_diagnostics
ctdb/tools/ctdb_natgw

index 139b406a5a8e1b4c047ec1873a82bb348e97b798..0a428516f597dd0ccdcdf455ed56413b5b51c2a0 100755 (executable)
@@ -127,6 +127,8 @@ show_and_compare_files () {
 
            if $first ; then
                onnode "$n" [ -r "$f" ] || {
+                   # This function takes a format string
+                   # shellcheck disable=SC2059
                    msg=$(printf "$fmt" "$f" "$n")
                    error "$msg"
                    continue 2;
index 9661cae2dead135d3e642c55f0f4442cdd288f74..448d00519eb1c204dcd8bc26178147a8edca8e18 100755 (executable)
@@ -148,7 +148,15 @@ nodes_list ()
        if [ "$_ip" = "$_master_ip" ] ; then
            _options="MASTER${_options:+,}${_options}"
        fi
-       printf "${_ip}${_options:+\t}${_options}\n"
+       # There is no other way to do this and keep shellcheck happy.
+       # The tab character must be in the format string and the
+       # format string must contain no variables.  Some shells will
+       # expand a tab if it is in an argument but others won't.
+       if [ -n "$_options" ] ; then
+               printf "%s\t%s\n" "$_ip" "$_options"
+       else
+               echo "$_ip"
+       fi
     done <<EOF
 $natgw_nodes
 EOF