commit:     6dea8b6b960b3370461a1b42c05f101bf42c89a4
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Jun  9 22:44:10 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  9 22:47:49 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=6dea8b6b

Address a slew of shellcheck warnings

False-positives galore. It's getting out of hand for test-functions, so
I disabled several more tests in its global scope. It was correct to
point out that "${PWD}" should be quoted, however. Bash doesn't mind but
other sh implementations might.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 functions.sh.in |  4 +++-
 test-functions  | 18 ++++++++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/functions.sh.in b/functions.sh.in
index d4becf8..76f1ad4 100644
--- a/functions.sh.in
+++ b/functions.sh.in
@@ -547,11 +547,13 @@ is_int() {
 #
 chdir() {
        if [ "$BASH" ]; then
+               # shellcheck disable=3044
                shopt -u cdable_vars
        fi
        if [ "$1" = - ]; then
                set -- ./-
        fi
+       # shellcheck disable=1007,2164
        CDPATH= cd -- "$@"
 }
 
@@ -648,7 +650,7 @@ _update_cursor_coords() {
 }
 
 _ecma48_cpr() {
-       @GENTOO_LIBEXEC_DIR@/ecma48-cpr "$@"
+       @GENTOO_LIBEXEC_DIR@/ecma48-cpr
 }
 
 # This is the main script, please add all functions above this point!

diff --git a/test-functions b/test-functions
index 9f87e98..34dc8b8 100755
--- a/test-functions
+++ b/test-functions
@@ -1,5 +1,5 @@
 #!/bin/sh
-# shellcheck disable=2015
+# shellcheck disable=2015,2154,2164,2181,2317
 
 # Requires mktemp(1), which is not a standard utility, but is commonly
 # available. The implementations provided by GNU coreutils, busybox and toybox
@@ -43,9 +43,10 @@ test_chdir() {
                shift
                test_description="chdir $(print_args "$@")"
                if [ "$BASH" ]; then
+                       # shellcheck disable=3044
                        shopt -s cdable_vars
                fi
-               CDPATH=child var=$CDPATH chdir "$@" \
+               CDPATH=child var=child chdir "$@" \
                && test "$PWD" != "$OLDPWD" \
                && cd - >/dev/null
        }
@@ -221,8 +222,8 @@ test_is_identifier() {
                1   [Z   \
                1  '`a'  \
                1  '`Z'  \
-               1   {a   \
-               1   {Z   \
+               1  '{a'  \
+               1  '{Z'  \
                1  '|a'  \
                1  '|Z'  \
                1   a/   \
@@ -233,8 +234,8 @@ test_is_identifier() {
                1   Z[   \
                1  'a`'  \
                1  'Z`'  \
-               1   a{   \
-               1   Z{   \
+               1  'a{'  \
+               1  'Z{'  \
                1  'a|'  \
                1  'Z|'  \
                0    a   \
@@ -351,6 +352,7 @@ test_yesno() {
                1  '_"; set -- yes # code injection' \
                0  truthful_nameref
 
+               # shellcheck disable=2034
                truthful_nameref=yes
 
                callback() {
@@ -433,8 +435,8 @@ fi
 # ecma48-cpr utility will not yet have been installed. Account for that by
 # redeclaring its shim function.
 if [ "${EBUILD_PHASE}" = test ]; then
-       export BUILD_DIR=${PWD}
-       _ecma48_cpr() { "${BUILD_DIR}"/ecma48-cpr "$@"; }
+       export BUILD_DIR="${PWD}"
+       _ecma48_cpr() { "${BUILD_DIR}"/ecma48-cpr; }
 fi
 
 assign_tmpdir

Reply via email to