From aa5187510f599da9b2dc4f048f37592c1667fbd8 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 14 Jul 2016 12:08:04 +1000 Subject: [PATCH] ctdb-scripts: Avoid shellcheck warning SC2059 ($ in printf format) SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo". Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/tools/ctdb_diagnostics | 2 ++ ctdb/tools/ctdb_natgw | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ctdb/tools/ctdb_diagnostics b/ctdb/tools/ctdb_diagnostics index 139b406a5a8..0a428516f59 100755 --- a/ctdb/tools/ctdb_diagnostics +++ b/ctdb/tools/ctdb_diagnostics @@ -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; diff --git a/ctdb/tools/ctdb_natgw b/ctdb/tools/ctdb_natgw index 9661cae2dea..448d00519eb 100755 --- a/ctdb/tools/ctdb_natgw +++ b/ctdb/tools/ctdb_natgw @@ -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 <