Skip to content

Commit

Permalink
Fixes shellcheck warnings (#75)
Browse files Browse the repository at this point in the history
* MODIFY: Declare and assign separately to avoid masking return values

For Shellcheck SC2155

* DELETE: Unused variables

* MODIFY: Double quote to prevent globbing and word splitting

Addresses SC2086

* DELETE: Remove unused variable

Addresses SC2034

* MODIFY: Remove use of expr

Addresses SC2003 and SC2004

* Remove spaces around COLOR options

Thanks to @cclaus
#75 (comment)

Co-authored-by: Christian Clauss <[email protected]>

---------

Co-authored-by: Christian Clauss <[email protected]>
  • Loading branch information
Arkoprabho and cclauss authored Aug 28, 2023
1 parent a2d7c08 commit 61032d6
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions has
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@ if [[ ! -t 1 ]]; then
elif [[ -z $TERM ]]; then
TERM="xterm"
fi
readonly txtreset="$(tput -T $TERM sgr0)"
readonly txtbold="$(tput -T $TERM bold)"
readonly txtblack="$(tput -T $TERM setaf 0)"
readonly txtred="$(tput -T $TERM setaf 1)"
readonly txtgreen="$(tput -T $TERM setaf 2)"
readonly txtyellow="$(tput -T $TERM setaf 3)"
readonly txtblue="$(tput -T $TERM setaf 4)"
readonly txtpurple="$(tput -T $TERM setaf 5)"
readonly txtcyan="$(tput -T $TERM setaf 6)"
readonly txtwhite="$(tput -T $TERM setaf 7)"

txtreset="$(tput -T "$TERM" sgr0)"
readonly txtreset

txtbold="$(tput -T "$TERM" bold)"
readonly txtbold

txtred="$(tput -T "$TERM" setaf 1)"
readonly txtred

txtgreen="$(tput -T "$TERM" setaf 2)"
readonly txtgreen

txtyellow="$(tput -T "$TERM" setaf 3)"
readonly txtyellow

# unicode "✗"
readonly fancyx='\342\234\227'
# unicode "✓"
Expand All @@ -38,7 +44,7 @@ readonly FAIL="${txtbold}${txtred}${fancyx}${txtreset}"
COLOR_AUTO="auto"
COLOR_NEVER="never"
COLOR_ALWAYS="always"
COLOR_OPTS=(${COLOR_AUTO} ${COLOR_NEVER} ${COLOR_ALWAYS})
COLOR_OPTS=("${COLOR_AUTO} ${COLOR_NEVER} ${COLOR_ALWAYS}")
COLOR="${COLOR_AUTO}"
COLOR_PREFIX="--color"

Expand Down Expand Up @@ -335,7 +341,6 @@ OUTPUT=/dev/stdout
while getopts ":qhv-" OPTION; do
case "$OPTION" in
q)
QUIET="true"
OUTPUT=/dev/null
;;
h)
Expand All @@ -347,10 +352,10 @@ while getopts ":qhv-" OPTION; do
exit 0
;;
-)
[ $OPTIND -ge 1 ] && optind=$(expr $OPTIND - 1) || optind=$OPTIND
[ $OPTIND -ge 1 ] && optind=$((OPTIND - 1)) || optind=$OPTIND
eval OPTION="\$$optind"
OPTARG=$(echo $OPTION | cut -d'=' -f2)
OPTION=$(echo $OPTION | cut -d'=' -f1)
OPTARG=$(echo "$OPTION" | cut -d'=' -f2)
OPTION=$(echo "$OPTION" | cut -d'=' -f1)
case $OPTION in
--version)
_version
Expand Down

0 comments on commit 61032d6

Please sign in to comment.