From 3706636a765351d6b341dfe3da383f78c471ef85 Mon Sep 17 00:00:00 2001 From: Vladimir Zhelezov Date: Tue, 8 Dec 2020 09:07:39 +0100 Subject: [PATCH] Fix or silence shellcheck warnings There are a couple of places where (un)quoting is intentionally skipped so make those explicit. --- shell-completion/hledger-completion.bash | 9 +++++++-- shell-completion/hledger-completion.bash.m4 | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/shell-completion/hledger-completion.bash b/shell-completion/hledger-completion.bash index ba1c95591..a834967e8 100644 --- a/shell-completion/hledger-completion.bash +++ b/shell-completion/hledger-completion.bash @@ -1,3 +1,5 @@ +# shellcheck disable=2034 + # Completion script for hledger. # Created using a Makefile and real hledger. @@ -67,6 +69,7 @@ _hledger_completion_function() { # -> always add accounts to completion list # Except for those few that will complain local noQuery=(files help test) + # shellcheck disable=2076 [[ " ${noQuery[*]} " =~ " $subcommand " ]] && return # Add any other subcommand special treatment here, or if it becomes unwieldy # move it out in say _hledger_compreply_subcommand() and return on success. @@ -119,12 +122,12 @@ _hledger_debug() { # `compgen' which requires its arguments quoted/escaped: _hledger_quote_by_ref() { - printf -v $2 %q "$1" + printf -v "$2" %q "$1" # If result becomes quoted like this: $'string', re-evaluate in order to # drop the additional quoting. See also: http://www.mail-archive.com/ # bash-completion-devel@lists.alioth.debian.org/msg01942.html - [[ ${!2} == \$* ]] && eval $2=${!2} + [[ ${!2} == \$* ]] && eval "$2=${!2}" } _hledger_quote() @@ -137,12 +140,14 @@ _hledger_quote() # Set the value of COMPREPLY from newline delimited completion candidates _hledger_compreply() { local IFS=$'\n' + # shellcheck disable=2206 COMPREPLY=($1) } # Append the value of COMPREPLY from newline delimited completion candidates _hledger_compreply_append() { local IFS=$'\n' + # shellcheck disable=2206 COMPREPLY+=($1) } diff --git a/shell-completion/hledger-completion.bash.m4 b/shell-completion/hledger-completion.bash.m4 index bfc48b15b..61ed03979 100644 --- a/shell-completion/hledger-completion.bash.m4 +++ b/shell-completion/hledger-completion.bash.m4 @@ -1,3 +1,5 @@ +# shellcheck disable=2034 + # Completion script for hledger. # Created using a Makefile and real hledger. @@ -67,6 +69,7 @@ _hledger_completion_function() { # -> always add accounts to completion list # Except for those few that will complain local noQuery=(files help test) + # shellcheck disable=2076 [[ " ${noQuery[*]} " =~ " $subcommand " ]] && return # Add any other subcommand special treatment here, or if it becomes unwieldy # move it out in say _hledger_compreply_subcommand() and return on success. @@ -119,12 +122,12 @@ _hledger_debug() { # `compgen' which requires its arguments quoted/escaped: _hledger_quote_by_ref() { - printf -v $2 %q "$1" + printf -v "$2" %q "$1" # If result becomes quoted like this: $'string', re-evaluate in order to # drop the additional quoting. See also: http://www.mail-archive.com/ # bash-completion-devel@lists.alioth.debian.org/msg01942.html - [[ ${!2} == \$* ]] && eval $2=${!2} + [[ ${!2} == \$* ]] && eval "$2=${!2}" } _hledger_quote() @@ -137,12 +140,14 @@ _hledger_quote() # Set the value of COMPREPLY from newline delimited completion candidates _hledger_compreply() { local IFS=$'\n' + # shellcheck disable=2206 COMPREPLY=($1) } # Append the value of COMPREPLY from newline delimited completion candidates _hledger_compreply_append() { local IFS=$'\n' + # shellcheck disable=2206 COMPREPLY+=($1) }