From 1fbfc141ee73d2a8911e969ff644aad6e7b3c276 Mon Sep 17 00:00:00 2001 From: fabolous005 Date: Sun, 29 Sep 2024 20:26:56 +0200 Subject: [PATCH] fix/document all shellcheck warnings --- etools | 11 ++++++++--- helper.sh | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/etools b/etools index b12b632..10fee50 100644 --- a/etools +++ b/etools @@ -22,6 +22,7 @@ function etools_smart_find() { eerror "no valid repository name" && return 2; . ./helper.sh if [[ "${2}" == /* ]]; then + # rely on word splitting for all of these # shellcheck disable=SC2046 _most_probable "$1" $(_filter $(_formatted_find "$@")) else @@ -42,9 +43,11 @@ function etools_smart_find() { # NOTE: get latest enabled version for a given package name function etools_get_version() { [ -z "$1" ] && eerror "Pass a package name to this function" "\n" && return 2; - [ ! -d ${ETOOLS_REPO_PATH}/*/$1 ] && \ + # in this case globs work with -d + # shellcheck disable=SC2144 + [ ! -d "${ETOOLS_REPO_PATH}"/*/"$1" ] && \ [ "$ETOOLS_DEBUG" ] && einfo "checked path ${ETOOLS_REPO_PATH}/*/$1" "\n" && \ - [ ! -d /var/db/repos/*/$1 ] && \ + [ ! -d /var/db/repos/*/"$1" ] && \ [ "$ETOOLS_DEBUG" ] && einfo "checked path /var/db/repos/*/$1" "\n" && \ eerror "Pass a package name to this function" "\n" && \ return 2; @@ -52,7 +55,9 @@ function etools_get_version() { local latest=: . ./helper.sh [ "$ETOOLS_CHECK_LIVE" ] && if _matches_live "$1"; then - latest="$(ls -1vr ${ETOOLS_REPO_PATH:-/var/db/repos}/*/$1/*9999*.ebuild | head "-${2:-1}" 2>/dev/null)" + # use ls over find for simplicity + # shellcheck disable=SC2012 + latest="$(ls -1vr "${ETOOLS_REPO_PATH:-/var/db/repos}"/*/"$1"/*9999*.ebuild | head "-${2:-1}" 2>/dev/null)" [ -n "$latest" ] && _extract_version "$latest" && ./helper.sh && return 0; fi if [ "$ETOOLS_CHECK_TESTING" ]; then diff --git a/helper.sh b/helper.sh index 38b1140..4bf040a 100755 --- a/helper.sh +++ b/helper.sh @@ -183,9 +183,13 @@ function _matches_testing() { function _get_latest() { local offset=$2 local latest=: - shopt -s globstar nullglob - for ebuild in $(ls -1vr /var/db/repos/*/$1/*.ebuild); do + # shopt -s globstar nullglob + # use ls for simplicity + # shellcheck disable=SC2045 + for ebuild in $(ls -1vr /var/db/repos/*/"$1"/*.ebuild); do if [[ ! "$ebuild" == *"9999"* ]]; then + # we can't specify the source for this + # shellcheck disable=SC1090 . "$ebuild" >>/dev/null 2>/dev/null if [[ "$KEYWORDS" == *"$3"* ]]; then latest="$ebuild"