]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Avoid shellcheck warning SC2039 (echo -n)
authorMartin Schwenke <martin@meltin.net>
Wed, 6 Jul 2016 20:41:27 +0000 (06:41 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 21 Jul 2016 00:24:26 +0000 (02:24 +0200)
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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/ctdb.init
ctdb/config/events.d/13.per_ip_routing
ctdb/config/events.d/20.multipathd
ctdb/config/functions

index f7ba95ced69de58f5674718624f2e02fedf5934d..b9c0a6deb0f45ef66c7805e2c1a90ca19f6def54 100755 (executable)
@@ -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)
@@ -85,7 +85,7 @@ start()
 
 stop()
 {
-    echo -n "Shutting down ctdbd service: "
+    printf "Shutting down ctdbd service: "
 
     case "$CTDB_INIT_STYLE" in
        suse)
index 9b16138da6e74772c3fa0cca9c6fa672bc5e8322..cfb8348078e41bc7d21bb396a222e849ed79f059 100755 (executable)
@@ -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
index f12ead6bd05e429fc90ad9bff4cf0ee18bc4f216..3dd58dae8ad3f7b6b0cdb6164fd542b20bda8ebb 100755 (executable)
@@ -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
@@ -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
index be308e7b3a2f14ce09732b6d5381548d79cfe06e..603cbf0a4908f2f8e95543d58d28c82831d78eb7 100755 (executable)
@@ -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"