Skip to content

Commit

Permalink
ctdb-scripts: Avoid shellcheck warning SC2039 (echo -n)
Browse files Browse the repository at this point in the history
SC2039: In POSIX sh, echo flags are not supported.

echo -n is well supported but the changes are simple.

Improve some logic, replace some instances with printf.  Who knew
printf was in POSIX?

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 f43df8f commit d7f3b19
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ctdb/config/ctdb.init
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pidfile="${CTDB_PIDFILE:-/var/run/ctdb/ctdbd.pid}"

start()
{
echo -n "Starting ctdbd service: "
printf "Starting ctdbd service: "

case "$CTDB_INIT_STYLE" in
suse)
Expand All @@ -85,7 +85,7 @@ start()

stop()
{
echo -n "Shutting down ctdbd service: "
printf "Shutting down ctdbd service: "

case "$CTDB_INIT_STYLE" in
suse)
Expand Down
2 changes: 1 addition & 1 deletion ctdb/config/events.d/13.per_ip_routing
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ get_config_for_ip ()
# that we get the maskbits as item #2 without further parsing.
while IFS="/$IFS" read _i _maskbits _x ; do
if [ "$_ip" = "$_i" ] ; then
echo -n "$_ip "; ipv4_host_addr_to_net "$_ip" "$_maskbits"
printf "%s" "$_ip "; ipv4_host_addr_to_net "$_ip" "$_maskbits"
fi
done <"${CTDB_PUBLIC_ADDRESSES:-/dev/null}"
else
Expand Down
7 changes: 4 additions & 3 deletions ctdb/config/events.d/20.multipathd
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ multipathd_check_background()
# Check multipath knows about the device
_out=$(multipath -ll "$_device")
if [ -z "$_out" ] ; then
echo "device \"${_device}\" not known to multipathd" >"$multipath_fail"
echo "ERROR: device \"${_device}\" not known to multipathd" \
>"$multipath_fail"
exit 1
fi

# Check for at least 1 active path
if ! echo "$_out" | grep 'prio=.* status=active' >/dev/null 2>&1 ; then
echo "multipath device \"${_device}\" has no active paths" >"$multipath_fail"
echo "ERROR: multipath device \"${_device}\" has no active paths" \
>"$multipath_fail"
exit 1
fi
done
Expand All @@ -58,7 +60,6 @@ multipathd_check()
if wait $_pid ; then
return 0
else
echo -n "ERROR: "
cat "$multipath_fail"
rm -f "$multipath_fail"
return 1
Expand Down
4 changes: 2 additions & 2 deletions ctdb/config/functions
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,8 @@ ctdb_counter_init () {
ctdb_counter_incr () {
_ctdb_counter_common "$1"

# unary counting!
echo -n 1 >> "$_counter_file"
# unary counting using newlines!
echo >>"$_counter_file"
}
ctdb_counter_get () {
_ctdb_counter_common "$1"
Expand Down

0 comments on commit d7f3b19

Please sign in to comment.