ctdb-scripts: Avoid shellcheck SC1117: Backslash is literal in "..."
authorMartin Schwenke <martin@meltin.net>
Thu, 19 Apr 2018 01:54:26 +0000 (11:54 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 27 Apr 2018 04:53:16 +0000 (06:53 +0200)
This warning (apparently new in shellcheck 0.4.7) only applies to
double-quoted strings.  Change affected constant strings to use
single-quotes.  In the one example that contains a variable expansion
escape the backslash as recommended.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/debug-hung-script.sh
ctdb/config/debug_locks.sh
ctdb/config/events.d/10.interface
ctdb/config/events.d/13.per_ip_routing
ctdb/tools/ctdb_natgw

index dc9c6e1ac7fbd1fd0948ad36971f9a47384c4e0c..d6ff833a43ed287607bbbdad965c441cebd2d003 100755 (executable)
@@ -36,7 +36,7 @@ fi
     default_pat='exportfs|rpcinfo'
     pat="${CTDB_DEBUG_HUNG_SCRIPT_STACKPAT:-${default_pat}}"
     echo "$out" |
-    sed -r -n "s@.*-(.*(${pat}).*),([0-9]*).*@\\1@p" |
+    sed -r -n "s@.*-(.*(${pat}).*),([0-9]*).*@\\3 \\1@p" |
     while read pid name ; do
        trace=$(cat "/proc/${pid}/stack" 2>/dev/null)
        # No! Checking the exit code afterwards is actually clearer...
index 0f8aaad67d22676f4a8b382746d82af5d35c7bf4..3feb121e2bacd0e0da42eff1cccd8607604d579c 100755 (executable)
@@ -39,7 +39,7 @@ loadconfig
     while read pid rest ; do
        pname=$(readlink "/proc/${pid}/exe")
        echo "$pid $pname $rest"
-    done | sed -e "$sed_cmd" | grep "\.tdb" )
+    done | sed -e "$sed_cmd" | grep '\.tdb' )
 
     if [ -n "$out" ]; then
        # Log information about locks
@@ -54,7 +54,7 @@ loadconfig
        done
        # Use word splitting to squash whitespace
        # shellcheck disable=SC2086
-       pids=$(echo $all_pids | tr " " "\n" | sort -u)
+       pids=$(echo $all_pids | tr ' ' '\n' | sort -u)
 
        # For each process waiting, log stack trace
        for pid in $pids ; do
index 28a7e5b11a391b81ee26059b290211283515d15e..72e0c101d472c65105ffce7859cc74692653ddde 100755 (executable)
@@ -25,9 +25,9 @@ fi
 get_all_interfaces ()
 {
     # Get all the interfaces listed in the public_addresses file
-    all_interfaces=$(sed -e "s/^[^\t ]*[\t ]*//" \
-                        -e "s/,/ /g" \
-                        -e "s/[\t ]*$//" "$ctdb_public_addresses")
+    all_interfaces=$(sed -e 's/^[^\t ]*[\t ]*//' \
+                        -e 's/,/ /g' \
+                        -e 's/[\t ]*$//' "$ctdb_public_addresses")
 
     # Get the interfaces for which CTDB has public IPs configured.
     # That is, for all but the 1st line, get the 1st field.
index ae5a0b9186aae1ad77b7431305dcbe14a99ef351..269829483abd644e82ac8b4a660adb09a9a47487 100755 (executable)
@@ -158,7 +158,7 @@ ensure_table_id_for_ip ()
        # If the new table id is legal then add it to the file and
        # print it.
        if [ "$_new" -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] ; then
-           printf "%d\t%s\n" "$_new" "$_label" >>"$rt_tables"
+           printf '%d\t%s\n' "$_new" "$_label" >>"$rt_tables"
            return 0
        else
            return 1
@@ -211,7 +211,7 @@ get_config_for_ip ()
     else
        while read _i _rest ; do
            if [ "$_ip" = "$_i" ] ; then
-               printf "%s\t%s\n" "$_ip" "$_rest"
+               printf '%s\t%s\n' "$_ip" "$_rest"
            fi
        done <"$CTDB_PER_IP_ROUTING_CONF"
     fi
index b17624155bf2c3dd7a53e62d0a78bf241ba007ab..21744ddfd0f22b9c7be012f72a823d4a67e55779 100755 (executable)
@@ -152,7 +152,7 @@ nodes_list ()
        # 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"
+               printf '%s\t%s\n' "$_ip" "$_options"
        else
                echo "$_ip"
        fi