Skip to content

Commit

Permalink
ctdb-scripts: Avoid shellcheck warning SC1004 (backslash in quotes)
Browse files Browse the repository at this point in the history
SC1004: You don't break lines with \ in single quotes, it results in
literal backslash-linefeed.

These don't hurt, since awk can cope with the continuations.  However,
they don't add anything.

Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
  • Loading branch information
martin-schwenke authored and Amitay Isaacs committed Jul 21, 2016
1 parent b208ae7 commit 0ca0026
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
6 changes: 3 additions & 3 deletions ctdb/config/events.d/13.per_ip_routing
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ clean_up_table_ids ()
awk -v min="$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" \
-v max="$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" \
-v pre="$table_id_prefix" \
'/^#/ || \
!(min <= $1 && $1 <= max) && \
!(index($2, pre) == 1) \
'/^#/ ||
!(min <= $1 && $1 <= max) &&
!(index($2, pre) == 1)
{ print $0 }' "$rt_tables" >"$_tmp"

mv "$_tmp" "$rt_tables"
Expand Down
9 changes: 4 additions & 5 deletions ctdb/config/functions
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,10 @@ ip_maskbits_iface ()
*:*) _bits=128 ;;
*) _bits=32 ;;
esac

ip addr show to "${_addr}/${_bits}" 2>/dev/null | \
awk 'NR == 1 { iface = $2; sub(":$", "", iface) ; \
sub("@.*", "", iface) } \
$1 ~ /inet/ { mask = $2; sub(".*/", "", mask); \
awk 'NR == 1 { iface = $2; sub(":$", "", iface) ;
sub("@.*", "", iface) }
$1 ~ /inet/ { mask = $2; sub(".*/", "", mask);
print mask, iface }'
}

Expand Down Expand Up @@ -671,7 +670,7 @@ interface_get_real ()

# Extract the full interface description to see if it is a VLAN
_t=$(echo "$_iface_info" |
awk 'NR == 1 { iface = $2; sub(":$", "", iface) ; \
awk 'NR == 1 { iface = $2; sub(":$", "", iface) ;
print iface }')
case "$_t" in
*@*)
Expand Down
8 changes: 4 additions & 4 deletions ctdb/config/statd-callout
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ case "$1" in
# hosted public IP addresses.
ctdb_ips=$($CTDB ip | tail -n +2)
sed_expr=$(echo "$ctdb_ips" |
awk -v pnn="$pnn" 'pnn == $2 { \
ip = $1; gsub(/\./, "\\.", ip); \
awk -v pnn="$pnn" 'pnn == $2 {
ip = $1; gsub(/\./, "\\.", ip);
printf "/statd-state@%s@/p\n", ip }')
# Intentional multi-word expansion for multiple files
# shellcheck disable=SC2086
Expand Down Expand Up @@ -165,8 +165,8 @@ case "$1" in
# but only for the server-IPs that are hosted on this node.
ctdb_all_ips=$($CTDB ip all | tail -n +2)
sed_expr=$(echo "$ctdb_all_ips" |
awk -v pnn="$pnn" 'pnn == $2 { \
ip = $1; gsub(/\./, "\\.", ip); \
awk -v pnn="$pnn" 'pnn == $2 {
ip = $1; gsub(/\./, "\\.", ip);
printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", ip }')

statd_state=$($CTDB catdb ctdb.tdb | sed -n "$sed_expr" | sort)
Expand Down
6 changes: 3 additions & 3 deletions ctdb/tools/ctdb_natgw
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ EOF
# BANNED or STOPPED)
awk -F '|' -v ms="$_ms" \
'BEGIN { ret = 2 }
ms ~ "@" $2 "@" && \
ms ~ "@" $2 "@" &&
$5 == 0 && $6 == 0 && $8 == 0 { print $1, $2 ; ret=0 ; exit }
END { exit ret }' <<EOF ||
$nodestatus_X
Expand All @@ -116,7 +116,7 @@ EOF
# DISCONNECTED, DISABLED or STOPPED
awk -F '|' -v ms="$_ms" \
'BEGIN { ret = 2 }
ms ~ "@" $2 "@" && \
ms ~ "@" $2 "@" &&
$3 == 0 && $5 == 0 && $7 == 0 { print $1, $2 ; ret=0 ; exit }
END { exit ret }' <<EOF ||
$nodestatus_X
Expand All @@ -125,7 +125,7 @@ EOF
# DISABLED
awk -F '|' -v ms="$_ms" \
'BEGIN { ret = 2 }
ms ~ "@" $2 "@" && \
ms ~ "@" $2 "@" &&
$3 == 0 && $5 == 0 { print $1, $2 ; ret=0 ; exit }
END { exit ret }' <<EOF
$nodestatus_X
Expand Down

0 comments on commit 0ca0026

Please sign in to comment.