* [Buildroot] [git commit] support/download/check-hash: fix shellcheck errors
@ 2024-04-01 15:03 Yann E. MORIN
2024-04-28 19:46 ` Peter Korsgaard
0 siblings, 1 reply; 2+ messages in thread
From: Yann E. MORIN @ 2024-04-01 15:03 UTC (permalink / raw)
To: buildroot
commit: https://git.buildroot.net/buildroot/commit/?id=9cb421c16f9aa026eabe050d94664c137f93eff5
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master
The hash files do not use trailing backslash \ to continue lines, so
we don't want them to be interpreted thusly, so we use 'read -r'
(SC2162).
The h_file is used twice in the same loop, once for reading from it,
and once just to print it, so there is no conflict (SC2094).
Integrer variables need not be quoted (SC2086). In any case, should
there be an actual issue and they be set empty, that would cause a
runtime issue, wether they be quoted or not.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
.checkpackageignore | 1 -
support/download/check-hash | 8 ++++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/.checkpackageignore b/.checkpackageignore
index 89814f4e9b..6f4bf67629 100644
--- a/.checkpackageignore
+++ b/.checkpackageignore
@@ -1434,7 +1434,6 @@ support/dependencies/check-host-xzcat.sh Shellcheck
support/dependencies/dependencies.sh Shellcheck
support/download/bzr ConsecutiveEmptyLines Shellcheck
support/download/cargo-post-process Shellcheck
-support/download/check-hash Shellcheck
support/download/cvs Shellcheck
support/download/dl-wrapper Shellcheck
support/download/file Shellcheck
diff --git a/support/download/check-hash b/support/download/check-hash
index 03a6557187..9db647885a 100755
--- a/support/download/check-hash
+++ b/support/download/check-hash
@@ -57,7 +57,7 @@ check_one_hash() {
esac
# Do the hashes match?
- _hash=$( ${_h}sum "${_file}" |cut -d ' ' -f 1 )
+ _hash="$( "${_h}sum" "${_file}" |cut -d ' ' -f 1 )"
if [ "${_hash}" = "${_known}" ]; then
printf "%s: OK (%s: %s)\n" "${base}" "${_h}" "${_hash}"
return 0
@@ -78,7 +78,8 @@ nb_checks=0
for h_file in "${h_files[@]}"; do
[ -f "${h_file}" ] || continue
: $((nb_h_files++))
- while read t h f; do
+ # shellcheck disable=SC2094 # we're really reading it only once
+ while read -r t h f; do
case "${t}" in
''|'#'*)
# Skip comments and empty lines
@@ -86,6 +87,7 @@ for h_file in "${h_files[@]}"; do
;;
*)
if [ "${f}" = "${base}" ]; then
+ # shellcheck disable=SC2094 # we're only printing the h_file filename
check_one_hash "${t}" "${h}" "${file}" "${h_file}"
: $((nb_checks++))
fi
@@ -94,11 +96,13 @@ for h_file in "${h_files[@]}"; do
done <"${h_file}"
done
+# shellcheck disable=SC2086 # nb_h_files is a non-empty int
if [ ${nb_h_files} -eq 0 ]; then
printf "WARNING: no hash file for %s\n" "${base}" >&2
exit 0
fi
+# shellcheck disable=SC2086 # nb_checks is a non-empty int
if [ ${nb_checks} -eq 0 ]; then
case " ${BR_NO_CHECK_HASH_FOR} " in
*" ${base} "*)
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Buildroot] [git commit] support/download/check-hash: fix shellcheck errors
2024-04-01 15:03 [Buildroot] [git commit] support/download/check-hash: fix shellcheck errors Yann E. MORIN
@ 2024-04-28 19:46 ` Peter Korsgaard
0 siblings, 0 replies; 2+ messages in thread
From: Peter Korsgaard @ 2024-04-28 19:46 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: buildroot
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
> commit: https://git.buildroot.net/buildroot/commit/?id=9cb421c16f9aa026eabe050d94664c137f93eff5
> branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master
> The hash files do not use trailing backslash \ to continue lines, so
> we don't want them to be interpreted thusly, so we use 'read -r'
> (SC2162).
> The h_file is used twice in the same loop, once for reading from it,
> and once just to print it, so there is no conflict (SC2094).
> Integrer variables need not be quoted (SC2086). In any case, should
> there be an actual issue and they be set empty, that would cause a
> runtime issue, wether they be quoted or not.
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Committed to 2024.02.x, thanks.
--
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-28 19:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-01 15:03 [Buildroot] [git commit] support/download/check-hash: fix shellcheck errors Yann E. MORIN
2024-04-28 19:46 ` Peter Korsgaard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.