From 6f59df0faa06e9e5b2127d8376b12bb1cf2db5fd Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sat, 5 Jun 2021 20:26:21 +0200 Subject: make shellcheck happy again --- bin/bootstrap-mysql | 2 +- bin/build-packages | 7 ++++--- bin/change-git-remotes | 2 +- bin/check-opcodes | 2 +- bin/clean-cache | 2 +- bin/clean-dependencies | 2 +- bin/db-update | 2 +- bin/delete-packages | 2 ++ bin/interpret-mail | 2 +- bin/slave-build-connect | 6 +++--- lib/common-functions | 2 +- lib/intentions-queue | 6 +++--- lib/load-configuration | 2 +- lib/mysql-functions | 13 +++++++------ 14 files changed, 28 insertions(+), 24 deletions(-) diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql index 711f3d1..fbcbc47 100755 --- a/bin/bootstrap-mysql +++ b/bin/bootstrap-mysql @@ -695,7 +695,7 @@ fi printf 'DELIMITER ;\n' - if [ "x$1" != 'x-no-privileges' ]; then + if [ "$1" != '-no-privileges' ]; then printf 'GRANT %s ON %s TO '"'"'buildmaster'"'"'@'"'"'localhost'"'"';\n' \ 'CREATE ROUTINE' 'buildmaster.*' \ 'CREATE TEMPORARY TABLES' 'buildmaster.*' \ diff --git a/bin/build-packages b/bin/build-packages index d73a440..9c5ab03 100755 --- a/bin/build-packages +++ b/bin/build-packages @@ -309,9 +309,10 @@ while [ "${count}" -ne 0 ] && \ if [ "${git_revision##*-}" = 'HEAD' ]; then git_revision=$( repo_name="${git_revision%-*}" - eval repo_path='"${repo_paths__'"${repo_name}"'}"' - if [ -z "${repo_path}" ]; then - >&2 printf 'Unknown git repository "%s".\n' "${repo_name}" + eval l_repo_path='"${repo_paths__'"${repo_name}"'}"' + # shellcheck disable=SC2154 + if [ -z "${l_repo_path}" ]; then + >&2 printf 'Unknown git repository "%s".\n' "${l_repo_name}" exit 2 fi git -C "${repo_path}" rev-parse HEAD diff --git a/bin/change-git-remotes b/bin/change-git-remotes index bc8e3f2..b7f687c 100755 --- a/bin/change-git-remotes +++ b/bin/change-git-remotes @@ -3,7 +3,7 @@ # shellcheck source=../lib/load-configuration . "${0%/*}/../lib/load-configuration" -if [ $# -eq 1 ] && [ "x$1" = 'x-q' ]; then +if [ $# -eq 1 ] && [ "$1" = '-q' ]; then quiet=true elif [ $# -ne 0 ]; then printf 'change-git-remotes [-q]\n' diff --git a/bin/check-opcodes b/bin/check-opcodes index e9f69a2..e8bb807 100755 --- a/bin/check-opcodes +++ b/bin/check-opcodes @@ -90,7 +90,7 @@ shift $((OPTIND-1)) PACKAGE=$1 -if test "x$PACKAGE" = "x"; then +if test "$PACKAGE" = ""; then echo "ERROR: Filename of a package required as argument" >&2 usage exit 1 diff --git a/bin/clean-cache b/bin/clean-cache index 8e6fb3c..21f1370 100755 --- a/bin/clean-cache +++ b/bin/clean-cache @@ -9,7 +9,7 @@ if [ $# -eq 0 ]; then dummynator='sudo' -elif [ $# -eq 1 ] && [ "x$1" = 'x-n' ]; then +elif [ $# -eq 1 ] && [ "$1" = '-n' ]; then dummynator='echo' else >&2 echo 'usage: clean-cache [-n]' diff --git a/bin/clean-dependencies b/bin/clean-dependencies index 82d49b3..63e9a9a 100755 --- a/bin/clean-dependencies +++ b/bin/clean-dependencies @@ -67,7 +67,7 @@ trap 'rm "${deps_file}"' EXIT printf 'INSERT IGNORE INTO `bps`(`bp`)' printf ' SELECT `deps`.`bp`' printf ' FROM `deps`;\n' - if [ $# -eq 1 ] && [ "x$1" = 'x-f' ]; then + if [ $# -eq 1 ] && [ "$1" = '-f' ]; then printf 'DELETE `dependencies`' else printf 'SELECT *' diff --git a/bin/db-update b/bin/db-update index 98d3fb1..88c567d 100755 --- a/bin/db-update +++ b/bin/db-update @@ -181,7 +181,7 @@ if [ -n "${only}" ]; then printf 's@^!%s\\(/.\\+\\)\\?$@' \ "${arch}" for arch2 in i486 i686 pentium4; do - if [ "${arch}" == "${arch2}" ]; then + if [ "${arch}" = "${arch2}" ]; then continue fi printf '%s\\1\\n' \ diff --git a/bin/delete-packages b/bin/delete-packages index a2e932c..2bb3072 100755 --- a/bin/delete-packages +++ b/bin/delete-packages @@ -152,6 +152,7 @@ export TMPDIR="${tmp_dir}" { printf 'CREATE TEMPORARY TABLE `bpir_to_delete` (`id` BIGINT, UNIQUE KEY (`id`));\n' printf 'INSERT IGNORE INTO `bpir_to_delete`' + # shellcheck disable=SC2030 if [ -n "${force_packages}" ]; then printf ' SELECT' printf ' `binary_packages_in_repositories`.`id`' @@ -342,6 +343,7 @@ export TMPDIR="${tmp_dir}" } ' +# shellcheck disable=SC2031 if [ -n "${build_support}" ] && \ [ -w "${build_support}" ] && \ [ ! -p "${build_support}" ]; then diff --git a/bin/interpret-mail b/bin/interpret-mail index 1d6bf7f..2580c00 100755 --- a/bin/interpret-mail +++ b/bin/interpret-mail @@ -1,6 +1,6 @@ #!/bin/sh -# shellcheck disable=SC2119,SC2120 +# shellcheck disable=SC2119,SC2120,SC3043 # shellcheck source=../lib/load-configuration . "${0%/*}/../lib/load-configuration" diff --git a/bin/slave-build-connect b/bin/slave-build-connect index e40dc32..40a227c 100755 --- a/bin/slave-build-connect +++ b/bin/slave-build-connect @@ -5,9 +5,9 @@ # shellcheck source=../lib/load-configuration . "${0%/*}/../lib/load-configuration" -if [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xget-assignment' ] || \ - [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xreturn-assignment' ] || \ - [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xping-from-slave' ]; then +if [ "${SSH_ORIGINAL_COMMAND%% *}" = 'get-assignment' ] || \ + [ "${SSH_ORIGINAL_COMMAND%% *}" = 'return-assignment' ] || \ + [ "${SSH_ORIGINAL_COMMAND%% *}" = 'ping-from-slave' ]; then # small check to prevent some shell-injections if printf '%s\n' "${SSH_ORIGINAL_COMMAND}" | \ diff --git a/lib/common-functions b/lib/common-functions index 4af92db..8c263ab 100755 --- a/lib/common-functions +++ b/lib/common-functions @@ -2,7 +2,7 @@ # contains functions used by more than one script -# shellcheck disable=SC2039,SC2119,SC2120 +# shellcheck disable=SC2039,SC2119,SC2120,SC3043 if [ -z "${base_dir}" ]; then # just to make shellcheck happy diff --git a/lib/intentions-queue b/lib/intentions-queue index c0d88a8..802d1ca 100755 --- a/lib/intentions-queue +++ b/lib/intentions-queue @@ -2,7 +2,7 @@ # contains functions related to the intentions-queue -# shellcheck disable=SC2039 +# shellcheck disable=SC2039,SC3043 if [ -z "${base_dir}" ]; then # just to make shellcheck happy @@ -15,7 +15,7 @@ fi # $package_database_lock_file externally intent_something() { local next_number - if [ "x$1" = 'x-n' ]; then + if [ "$1" = '-n' ]; then cat return fi @@ -75,7 +75,7 @@ execute_intention() { # with -n: return immediately # without -n: wait until nothing more to do intentions_left() { - if [ ! "x$1" = 'x-n' ]; then + if [ ! "$1" = '-n' ]; then while intentions_left -n; do sleep 1 done diff --git a/lib/load-configuration b/lib/load-configuration index 6b2d7ff..4c825f1 100755 --- a/lib/load-configuration +++ b/lib/load-configuration @@ -38,7 +38,7 @@ else fi # dirty hack to get this stuff debugable from a bash -if [ "x${0##*/}" = "x-bash" ] || [ "x${0##*/}" = "xbash" ] || [ "x${0##*/}" = "xdash" ]; then +if [ "${0##*/}" = "-bash" ] || [ "${0##*/}" = "bash" ] || [ "${0##*/}" = "dash" ]; then set +e if [ -z "${base_dir}" ]; then base_dir=$(pwd) diff --git a/lib/mysql-functions b/lib/mysql-functions index 6a6a1e7..af2c3ba 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -2,7 +2,7 @@ # contains functions used to access mysql db -# shellcheck disable=SC2016,SC2039,SC2119,SC2120 +# shellcheck disable=SC2016,SC2039,SC2119,SC2120,SC3043 if [ -z "${base_dir}" ]; then # just to make shellcheck happy @@ -35,7 +35,7 @@ mysql_run_query() { local number file_name_extra='' - if [ "x$1" = 'xunimportant' ]; then + if [ "$1" = 'unimportant' ]; then shift file_name_extra='unimportant_' elif [ -s "${work_dir}/build-master-sanity" ]; then @@ -47,7 +47,7 @@ mysql_run_query() { query_stdout="${query_stdin%.stdin}.stdout" query_stderr="${query_stdin%.stdin}.stderr" cat > "${query_stdin}" - for _ in {1..10}; do + for _ in $(seq 10); do if [ -f "${query_stdout}" ]; then wait_some_time 10 10 fi @@ -221,7 +221,8 @@ mysql_generate_package_metadata() { mod_git_revision="$4" repository="$5" - if [[ "${current_repository_id}" = *[!0-9]* ]]; then + if printf '%s\n' "${current_repository_id}" \ + | grep -q '[^0-9]'; then >&2 printf 'mysql_generate_package_metadata(): invalid current_repository_id="%s".\n' \ "${current_repository_id}" exit 2 @@ -898,7 +899,7 @@ mysql_cleanup() { local operator if [ "$#" = '0' ]; then operator='DELETE' - elif [ "$#" = '1' ] && [ "x$1" = 'xdry' ]; then + elif [ "$#" = '1' ] && [ "$1" = 'dry' ]; then operator='SELECT COUNT(1)' else >&2 echo 'Unknown parameter' @@ -1558,7 +1559,7 @@ mysql_sort_versions() { ( # new shell is intentional tmp_file=$(mktemp 'tmp.mysql_sort_versions.XXXXXXXXXX' --tmpdir) trap 'rm "${tmp_file}"' EXIT - if [ "x$1" != 'x-f' ] && \ + if [ "$1" != '-f' ] && \ { printf 'SELECT' printf ' COUNT(1)' -- cgit v1.2.3