scripts: fix up some shellcheck cruft

These are not new issues, but moving git-utils.sh to a different
directory caused our differential spellcheck setup in CodeQL to start
complaining about them again.

Instead of waiving them, let's fix them.  Most of them are bogus, but
there's a couple of good catches too.
This commit is contained in:
Allison Karlitskaya 2023-05-26 11:51:23 +02:00
parent 246668d75c
commit 095e547cb8
3 changed files with 14 additions and 3 deletions

View File

@ -1,9 +1,11 @@
# shellcheck shell=sh
# doesn't do anything on its own. must be sourced.
# The script which sources this script must set the following variables:
# GITHUB_REPO = the relative repo name of the submodule on github
# SUBDIR = the location in the working tree where the submodule goes
# We also expect `set -eu`.
# We also expect `set -eu`, but set them ourselves for shellcheck.
set -eu
[ -n "${GITHUB_REPO}" ]
[ -n "${SUBDIR}" ]
@ -13,6 +15,7 @@ unset GIT_DIR GIT_EXEC_PATH GIT_PREFIX GIT_REFLOG_ACTION GIT_WORK_TREE
GITHUB_BASE="${GITHUB_BASE:-cockpit-project/cockpit}"
GITHUB_REPOSITORY="${GITHUB_BASE%/*}/${GITHUB_REPO}"
HTTPS_REMOTE="https://github.com/${GITHUB_REPOSITORY}"
# shellcheck disable=SC2034 # used in other scripts
SSH_REMOTE="git@github.com:${GITHUB_REPOSITORY}"
CACHE_DIR="${XDG_CACHE_HOME-${HOME}/.cache}/cockpit-dev/${GITHUB_REPOSITORY}.git"
@ -118,6 +121,7 @@ tar_to_cache() {
# Use a sub-shell to enable cleanup of the temporary directory
(
tmpdir="$(mktemp --tmpdir --directory cockpit-tar-to-git.XXXXXX)"
# shellcheck disable=SC2064 # we want ${tmpdir} expanded now
trap "rm -r '${tmpdir}'" EXIT
export GIT_INDEX_FILE="${tmpdir}/tmp-index"

View File

@ -10,6 +10,7 @@ V="${V-0}" # default to friendly messages
set -eu
cd "${0%/*}/../.."
# shellcheck source-path=SCRIPTDIR/../..
. test/common/git-utils.sh
if [ ! -e bots ]; then

View File

@ -1,5 +1,8 @@
#!/bin/sh
# shellcheck disable=SC3043 # local is not POSIX, but every shell has it
# shellcheck disable=SC3013,SC3045 # ditto for test {-nt,-t}
GITHUB_REPO='node-cache'
SUBDIR='node_modules'
@ -7,6 +10,7 @@ V="${V-0}" # default to friendly messages
set -eu
cd "${0%/*}/.."
# shellcheck source-path=SCRIPTDIR/..
. test/common/git-utils.sh
cmd_remove() {
@ -129,7 +133,8 @@ cmd_make_package_lock_json() {
# Otherwise, our main goal is to ensure that the node_modules from
# the index is the one that we actually have.
local sha="$(get_index_gitlink node_modules)"
local sha
sha="$(get_index_gitlink node_modules)"
if [ ! -e node_modules/.git ]; then
# nothing there yet...
cmd_checkout
@ -172,7 +177,8 @@ main() {
exit 1
fi
local fname="$(printf 'cmd_%s' "$1" | tr '-' '_')"
local fname
fname="$(printf 'cmd_%s' "$1" | tr '-' '_')"
if ! type -t "${fname}" | grep -q function; then
echo "Unknown subcommand '$1'"
exit 1