From cb9bb3250d1df26b8586bd741bd049ac824983ff Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Mon, 17 Jul 2023 16:42:05 -0600 Subject: [PATCH 01/73] Remove runfiles from files.sh. --- shlib/lib/BUILD.bazel | 5 +---- shlib/lib/files.sh | 22 ++++------------------ 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/shlib/lib/BUILD.bazel b/shlib/lib/BUILD.bazel index ff919836..23e6d72e 100644 --- a/shlib/lib/BUILD.bazel +++ b/shlib/lib/BUILD.bazel @@ -23,10 +23,7 @@ sh_library( sh_library( name = "files", srcs = ["files.sh"], - deps = [ - ":paths", - "@bazel_tools//tools/bash/runfiles", - ], + deps = [":paths"], ) sh_library( diff --git a/shlib/lib/files.sh b/shlib/lib/files.sh index 4498eb24..e1cb8d17 100644 --- a/shlib/lib/files.sh +++ b/shlib/lib/files.sh @@ -1,27 +1,13 @@ #!/usr/bin/env bash -# Since we are in a library, check if rlocation has been defined yet. -if [[ $(type -t rlocation) != function ]]; then - # --- begin runfiles.bash initialization v3 --- - # Copy-pasted from the Bazel Bash runfiles library v3. - set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash - source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ - source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ - source "$0.runfiles/$f" 2>/dev/null || \ - source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ - source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ - { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e - # --- end runfiles.bash initialization v3 --- -fi +# This is used to determine if the library has been loaded +cgrindel_bazel_shlib_lib_files_loaded() { return; } if [[ $(type -t cgrindel_bazel_shlib_lib_paths_loaded) != function ]]; then - paths_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/paths.sh)" - source "${paths_lib}" + # shellcheck source=SCRIPTDIR/paths.sh + source "shlib/lib/paths.sh" fi -# This is used to determine if the library has been loaded -cgrindel_bazel_shlib_lib_files_loaded() { return; } - # Recursively searches for a file starting from the current directory up to the root of the filesystem. # # Flags: From a1bb8327cbbea27c10497b705530b9ae6eec17d2 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Mon, 17 Jul 2023 16:43:42 -0600 Subject: [PATCH 02/73] Address ShellCheck issues in files.sh --- shlib/lib/files.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shlib/lib/files.sh b/shlib/lib/files.sh index e1cb8d17..3378a8c5 100644 --- a/shlib/lib/files.sh +++ b/shlib/lib/files.sh @@ -29,7 +29,8 @@ upsearch() { while (("$#")); do case "${1}" in "--start_dir") - local start_dir="$(normalize_path "${2}")" + local start_dir + start_dir="$(normalize_path "${2}")" shift 2 ;; "--error_if_not_found") From 82c3aee5f0cfcfd2dccc8031e64f8cfd51c639ae Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Mon, 17 Jul 2023 16:45:02 -0600 Subject: [PATCH 03/73] Address ShellCheck issues in arrays.sh. --- shlib/lib/arrays.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/shlib/lib/arrays.sh b/shlib/lib/arrays.sh index 90d8bdf9..f9a5ae78 100644 --- a/shlib/lib/arrays.sh +++ b/shlib/lib/arrays.sh @@ -43,7 +43,7 @@ join_by() { local delimiter="${1}" shift 1 printf -v joined '%s'"${delimiter}" "${@}" - echo "${joined%${delimiter}}" + echo "${joined%"${delimiter}"}" } # GH076: Figure out how to handle returning items with spaces. @@ -107,7 +107,7 @@ contains_item() { # Do a quick regex to see if the value is in the rest of the args # If not, then don't bother looping - [[ ! "${*}" =~ "${x}" ]] && return -1 + [[ ! "${*}" =~ ${x} ]] && return 1 # Loop through items for a precise match for it in "${@}" ; do @@ -115,7 +115,7 @@ contains_item() { done # We did not find the item - return -1 + return 1 } # Searches for the expected value in the follow-on arguments. This function assumes that the list @@ -139,35 +139,37 @@ contains_item_sorted() { # s: start index # e: end index # m: midpoint index + # mv: midpoint value # Remember the expected value local x="${1}" shift # Don't preceed if we have no list items. - [[ ${#} == 0 ]] && return -1 + [[ ${#} -eq 0 ]] && return 1 # Init the start and end indexes local s=1 local e=${#} - while [[ 0 == 0 ]]; do + while true; do # Find midpoint - local m=$(( ${s} + (${e} - ${s} + 1)/2 )) + local m=$(( s + (e - s + 1)/2 )) # If the midpoint value (!m) is the expected, found it - [[ "${x}" == "${!m}" ]] && return + local mv="${!m}" + [[ "${x}" == "${mv}" ]] && return # If the start index and end index are the same, finished searching - [[ ${s} == ${e} ]] && return -1 + [[ $s -eq $e ]] && return 1 # Update the start/end index based upon whether the expected is greater # than or less than the midpoint value. - if [[ "${x}" < "${!m}" ]]; then - local e=$(( ${m} - 1 )) + if [[ "${x}" < "${mv}" ]]; then + local e=$(( m - 1 )) else - [[ ${m} == ${e} ]] && return -1 - local s=$(( ${m} + 1 )) + [[ $m -eq $e ]] && return 1 + local s=$(( m + 1 )) fi done } From 3b2749ce2a1b388f9a2d48e7fba7a99a31d7fe0a Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Mon, 17 Jul 2023 17:20:40 -0600 Subject: [PATCH 04/73] Address ShellCheck issues in assertions.sh. --- shlib/lib/assertions.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shlib/lib/assertions.sh b/shlib/lib/assertions.sh index 0f8be820..9f40e123 100644 --- a/shlib/lib/assertions.sh +++ b/shlib/lib/assertions.sh @@ -40,7 +40,8 @@ make_err_msg() { assert_equal() { local expected="${1}" local actual="${2}" - local err_msg="$(make_err_msg "Expected to be equal. expected: ${expected}, actual: ${actual}" "${3:-}")" + local err_msg + err_msg="$(make_err_msg "Expected to be equal. expected: ${expected}, actual: ${actual}" "${3:-}")" [[ "${expected}" == "${actual}" ]] || fail "${err_msg}" } @@ -57,7 +58,8 @@ assert_equal() { assert_match() { local pattern=${1} local actual="${2}" - local err_msg="$(make_err_msg "Expected to match. pattern: ${pattern}, actual: ${actual}" "${3:-}")" + local err_msg + err_msg="$(make_err_msg "Expected to match. pattern: ${pattern}, actual: ${actual}" "${3:-}")" [[ "${actual}" =~ ${pattern} ]] || fail "${err_msg}" } @@ -74,7 +76,8 @@ assert_match() { assert_no_match() { local pattern=${1} local actual="${2}" - local err_msg="$(make_err_msg "Expected not to match. pattern: ${pattern}, actual: ${actual}" "${3:-}")" + local err_msg + err_msg="$(make_err_msg "Expected not to match. pattern: ${pattern}, actual: ${actual}" "${3:-}")" [[ "${actual}" =~ ${pattern} ]] && fail "${err_msg}" # Because this is a negative test, we need to end on a positive note if all is well. echo "" From 6addc3e94fc57722f4e6a265592a2f72372a85d1 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Mon, 17 Jul 2023 17:21:30 -0600 Subject: [PATCH 05/73] Address ShellCheck issues in fail.sh. --- shlib/lib/fail.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shlib/lib/fail.sh b/shlib/lib/fail.sh index eafc9af9..411217f4 100644 --- a/shlib/lib/fail.sh +++ b/shlib/lib/fail.sh @@ -35,6 +35,6 @@ usage_error() { } show_usage() { - echo "$(get_usage)" + get_usage exit 0 } From 97e959d515df9543b1cb001ea304497aa07fb26a Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Mon, 17 Jul 2023 17:25:03 -0600 Subject: [PATCH 06/73] Address ShellCheck issues in git.sh. --- shlib/lib/git.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/shlib/lib/git.sh b/shlib/lib/git.sh index 08958f57..6778da74 100644 --- a/shlib/lib/git.sh +++ b/shlib/lib/git.sh @@ -8,7 +8,6 @@ cgrindel_bazel_starlib_lib_private_git_loaded() { return; } # MARK - Default Values remote=origin -main_branch=main # Returns the URL for the git repository. It is typically in the form: # git@github.com:cgrindel/bazel-starlib.git @@ -34,7 +33,7 @@ fetch_latest_from_git_remote() { is_valid_release_tag() { local tag="${1}" - [[ "${tag}" =~ ^v?[0-9]+[.][0-9]+[.][0-9]+ ]] || return -1 + [[ "${tag}" =~ ^v?[0-9]+[.][0-9]+[.][0-9]+ ]] || return 1 } # Returns the commit hash for the provided branch or tag. @@ -45,7 +44,10 @@ get_git_commit_hash() { # Returns the list of release tags sorted by most recent to oldest. get_git_release_tags() { - local tags=( $(git tag --sort=refname -l) ) + local tags=() + while IFS=$'\n' read -r line; do tags+=("$line"); done < <( + git tag --sort=refname -l + ) [[ ${#tags[@]} == 0 ]] && return local release_tags=() for tag in "${tags[@]}" ; do @@ -57,12 +59,16 @@ get_git_release_tags() { git_tag_exists() { local target_tag="${1}" - local tags=( $(git tag) ) + # local tags=( $(git tag) ) + local tags=() + while IFS=$'\n' read -r line; do tags+=("$line"); done < <( + git tag + ) # Make sure that the for loop variable is not tag or something else common. for cur_tag in "${tags[@]}" ; do [[ "${cur_tag}" == "${target_tag}" ]] && return done - return -1 + return 1 } create_git_tag() { From 26e47802d35960c8b17c1e5334c3afdbd84f2ef4 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 07:12:14 -0600 Subject: [PATCH 07/73] Address ShellCheck issues in github.sh. --- shlib/lib/github.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/shlib/lib/github.sh b/shlib/lib/github.sh index e7df6cbc..1b87b617 100644 --- a/shlib/lib/github.sh +++ b/shlib/lib/github.sh @@ -64,9 +64,9 @@ _get_github_repo_pattern_index() { local repo_url="${1}" for (( i = 0; i < ${#_github_url_patterns[@]}; i++ )); do pattern="${_github_url_patterns[$i]}" - [[ "${repo_url}" =~ "${pattern}" ]] && echo $i && return + [[ "${repo_url}" =~ ${pattern} ]] && echo $i && return done - return -1 + return 1 } # Succeeds if the URL is a Github repo URL. Otherwise, it fails. @@ -78,7 +78,8 @@ is_github_repo_url() { # Return the Github repository owner from the repository URL. get_gh_repo_owner() { local repo_url="${1}" - local pattern_index=$( _get_github_repo_pattern_index "${repo_url}" ) + local pattern_index + pattern_index=$( _get_github_repo_pattern_index "${repo_url}" ) local sed_cmd="${_github_url_owner_sed_cmds[${pattern_index}]}" echo "${repo_url}" | sed -E -n "${sed_cmd}" } @@ -100,8 +101,10 @@ gh_release_exists() { # Returns a base URL suitable for API calls. get_gh_api_base_url() { local repo_url="${1}" - local owner="$( get_gh_repo_owner "${repo_url}" )" - local name="$( get_gh_repo_name "${repo_url}" )" + local owner + owner="$( get_gh_repo_owner "${repo_url}" )" + local name + name="$( get_gh_repo_name "${repo_url}" )" echo "https://api.github.com/repos/${owner}/${name}" } @@ -125,9 +128,9 @@ get_gh_changelog() { esac done - [[ ${#args[@]} > 0 ]] && fail "Received positional args when none were expected. args: ${args[@]}" + [[ ${#args[@]} -gt 0 ]] && fail "Received positional args when none were expected. args:" "${args[@]}" [[ ${#api_args[@]} == 0 ]] && fail "Expected one or more API args." # Execute the API call - gh api repos/{owner}/{repo}/releases/generate-notes "${api_args[@]}" --jq '.body' + gh api "repos/{owner}/{repo}/releases/generate-notes" "${api_args[@]}" --jq '.body' } From dc23c8cf6a76be1e603edb652c1d94837aaaf9fb Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 07:24:50 -0600 Subject: [PATCH 08/73] Address ShellCheck issues in messages.sh. --- shlib/lib/messages.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shlib/lib/messages.sh b/shlib/lib/messages.sh index 4a5fcf18..b3d69e70 100644 --- a/shlib/lib/messages.sh +++ b/shlib/lib/messages.sh @@ -24,7 +24,8 @@ exit_with_msg() { while (("$#")); do case "${1}" in "--exit_code") - local exit_code=${2} + local exit_code + exit_code=$(($2)) shift 2 ;; "--no_exit") From 49fb264f521c5748c746a614063ce8c484bb170e Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 07:25:36 -0600 Subject: [PATCH 09/73] Address ShellCheck issues in paths.sh. --- shlib/lib/paths.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shlib/lib/paths.sh b/shlib/lib/paths.sh index 5da865c0..39e44626 100644 --- a/shlib/lib/paths.sh +++ b/shlib/lib/paths.sh @@ -16,8 +16,10 @@ normalize_path() { if [[ -d "${path}" ]]; then local dirname="${path}" else - local dirname="$(dirname "${path}")" - local basename="$(basename "${path}")" + local dirname + dirname="$(dirname "${path}")" + local basename + basename="$(basename "${path}")" fi dirname="$(cd "${dirname}" > /dev/null && pwd)" if [[ -z "${basename:-}" ]]; then From fa407db90cdb822a1c05e2470c94489b2e34bcee Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 07:28:44 -0600 Subject: [PATCH 10/73] Address ShellCheck issues in decompress.sh.tmpl. --- shlib/rules/private/decompress.sh.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shlib/rules/private/decompress.sh.tmpl b/shlib/rules/private/decompress.sh.tmpl index c56b9567..6dbe92c0 100755 --- a/shlib/rules/private/decompress.sh.tmpl +++ b/shlib/rules/private/decompress.sh.tmpl @@ -35,7 +35,7 @@ cd "${run_dir}" # Execute the binary cmd=( "${RUNFILES_DIR}/{{EXEC_BINARY}}" ) -[[ ${#} > 0 ]] && cmd+=( "${@}" ) +[[ ${#} -gt 0 ]] && cmd+=( "${@}" ) "${cmd[@]}" # Finished From e291c16b29815fea6df262475f8fce64c4baff6d Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 07:34:15 -0600 Subject: [PATCH 11/73] Address ShellCheck issues in contains_items_perf_comparison.sh. --- shlib/tools/contains_item_perf_comparison.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/shlib/tools/contains_item_perf_comparison.sh b/shlib/tools/contains_item_perf_comparison.sh index 71739cc1..1752a50d 100755 --- a/shlib/tools/contains_item_perf_comparison.sh +++ b/shlib/tools/contains_item_perf_comparison.sh @@ -12,6 +12,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ # --- end runfiles.bash initialization v3 --- arrays_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/arrays.sh)" +# shellcheck source=SCRIPTDIR/../lib/arrays.sh source "${arrays_lib}" # MARK - Performance Tests @@ -20,7 +21,7 @@ test_iterations=${1:-100} create_array() { local item_count=${1} - local max_val=$(( ${item_count} - 1 )) + local max_val=$(( item_count - 1 )) local width=$(( ${#max_val} )) local output=() local val=0 @@ -31,7 +32,7 @@ create_array() { } do_contains_item_perf_test() { - for (( i = 0; i < $test_iterations; i++ )); do + for (( i = 0; i < test_iterations; i++ )); do for item in "${@}" ; do contains_item "${item}" "${@}" done @@ -39,7 +40,7 @@ do_contains_item_perf_test() { } do_contains_item_sorted_perf_test() { - for (( i = 0; i < $test_iterations; i++ )); do + for (( i = 0; i < test_iterations; i++ )); do for item in "${@}" ; do contains_item_sorted "${item}" "${@}" done @@ -52,7 +53,10 @@ echo "" array_sizes=(25 30 35 40 45 50) for size in "${array_sizes[@]}" ; do echo "array size: ${size}" - array=( $(create_array ${size}) ) + array=() + while IFS=$'\n' read -r line; do array+=("$line"); done < <( + create_array "${size}" + ) contains_item_time="$( (time do_contains_item_perf_test "${array[@]}") 2>&1 )" contains_item_sorted_time="$( (time do_contains_item_sorted_perf_test "${array[@]}") 2>&1 )" echo "contains_item: ${contains_item_time}" From 5ba0393f43f7263ca7ce19597ace3812a587fa04 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 07:36:42 -0600 Subject: [PATCH 12/73] Address ShellCheck in buildifier_test.sh. --- tests/bzlformat_tests/tools_tests/buildifier_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bzlformat_tests/tools_tests/buildifier_test.sh b/tests/bzlformat_tests/tools_tests/buildifier_test.sh index 85dc5891..1e2fb479 100755 --- a/tests/bzlformat_tests/tools_tests/buildifier_test.sh +++ b/tests/bzlformat_tests/tools_tests/buildifier_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/assertions.sh source "${assertions_sh}" buildifier_sh_location=cgrindel_bazel_starlib/bzlformat/tools/buildifier.sh From 70a0cb58b2228cc3d6be1b69a0a393250565181b Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 07:44:10 -0600 Subject: [PATCH 13/73] Address ShellCheck issues in missing_pkgs_test.sh. --- .../missing_pkgs_tests/missing_pkgs_test.sh | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/missing_pkgs_test.sh b/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/missing_pkgs_test.sh index c0c35d4b..acb76541 100755 --- a/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/missing_pkgs_test.sh +++ b/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/missing_pkgs_test.sh @@ -14,16 +14,19 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" paths_sh_location=cgrindel_bazel_starlib/shlib/lib/paths.sh paths_sh="$(rlocation "${paths_sh_location}")" || \ (echo >&2 "Failed to locate ${paths_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/paths.sh source "${paths_sh}" messages_sh_location=cgrindel_bazel_starlib/shlib/lib/messages.sh messages_sh="$(rlocation "${messages_sh_location}")" || \ (echo >&2 "Failed to locate ${messages_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/messages.sh source "${messages_sh}" buildozer_location=buildifier_prebuilt/buildozer/buildozer @@ -56,7 +59,9 @@ cd "${scratch_dir}" # MARK - Find the missing packages without exclusions -missing_pkgs=( $("${bazel}" run "//:bzlformat_missing_pkgs_find") ) +while IFS=$'\n' read -r line; do missing_pkgs+=("$line"); done < <( + "${bazel}" run "//:bzlformat_missing_pkgs_find" +) assert_msg="Missing packages, no exclusions" expected_array=(// //foo //foo/bar) assert_equal ${#expected_array[@]} ${#missing_pkgs[@]} "${assert_msg}" @@ -73,7 +78,10 @@ done # Add exclusions to the bzlformat_missing_pkgs "${buildozer}" 'add exclude //foo' //:bzlformat_missing_pkgs -missing_pkgs=( $("${bazel}" run "//:bzlformat_missing_pkgs_find") ) +missing_pkgs=() +while IFS=$'\n' read -r line; do missing_pkgs+=("$line"); done < <( + "${bazel}" run "//:bzlformat_missing_pkgs_find" +) assert_msg="Missing packages, with exclusions" expected_array=(// //foo/bar) assert_equal ${#expected_array[@]} ${#missing_pkgs[@]} "${assert_msg}" @@ -83,11 +91,14 @@ done # MARK - Fix the missing packages with exclusions -fix_pkgs=( $("${bazel}" run "//:bzlformat_missing_pkgs_fix") ) +fix_pkgs=() +while IFS=$'\n' read -r line; do fix_pkgs+=("$line"); done < <( + "${bazel}" run "//:bzlformat_missing_pkgs_fix" +) assert_msg="Update missing packages, with exclusions" -# Note: The expected array purposefully does not quote the message as the fix_pkgs array +# Note: The expected array purposefully does not quote the message as the fix_pkgs array # will parse each space-separated item. -expected_array=(Updating the following packages: // //foo/bar) +expected_array=("Updating the following packages:" // //foo/bar) assert_equal ${#expected_array[@]} ${#fix_pkgs[@]} "${assert_msg}" for (( i = 0; i < ${#expected_array[@]}; i++ )); do assert_equal "${expected_array[${i}]}" "${fix_pkgs[${i}]}" "${assert_msg}[${i}]" @@ -98,7 +109,10 @@ done # Remove exclusions from the bzlformat_missing_pkgs "${buildozer}" 'remove exclude //foo' //:bzlformat_missing_pkgs -missing_pkgs=( $("${bazel}" run "//:bzlformat_missing_pkgs_find") ) +missing_pkgs=() +while IFS=$'\n' read -r line; do missing_pkgs+=("$line"); done < <( + "${bazel}" run "//:bzlformat_missing_pkgs_find" +) assert_msg="Missing packages after removing exclusions" expected_array=(//foo) assert_equal ${#expected_array[@]} ${#missing_pkgs[@]} "${assert_msg}" @@ -106,11 +120,14 @@ for (( i = 0; i < ${#expected_array[@]}; i++ )); do assert_equal "${expected_array[${i}]}" "${missing_pkgs[${i}]}" "${assert_msg}[${i}]" done -fix_pkgs=( $("${bazel}" run "//:bzlformat_missing_pkgs_fix") ) +fix_pkgs=() +while IFS=$'\n' read -r line; do fix_pkgs+=("$line"); done < <( + "${bazel}" run "//:bzlformat_missing_pkgs_fix" +) assert_msg="Update missing packages after removing exclusions" -# Note: The expected array purposefully does not quote the message as the fix_pkgs array +# Note: The expected array purposefully does not quote the message as the fix_pkgs array # will parse each space-separated item. -expected_array=(Updating the following packages: //foo) +expected_array=("Updating the following packages:" //foo) assert_equal ${#expected_array[@]} ${#fix_pkgs[@]} "${assert_msg}" for (( i = 0; i < ${#expected_array[@]}; i++ )); do assert_equal "${expected_array[${i}]}" "${fix_pkgs[${i}]}" "${assert_msg}[${i}]" @@ -118,7 +135,10 @@ done # MARK - Confirm that finding no missing packages works -missing_pkgs=( $("${bazel}" run "//:bzlformat_missing_pkgs_find") ) +missing_pkgs=() +while IFS=$'\n' read -r line; do missing_pkgs+=("$line"); done < <( + "${bazel}" run "//:bzlformat_missing_pkgs_find" +) assert_msg="Expect no missing packages" expected_array=() assert_equal ${#expected_array[@]} ${#missing_pkgs[@]} "${assert_msg}" @@ -126,11 +146,14 @@ for (( i = 0; i < ${#expected_array[@]}; i++ )); do assert_equal "${expected_array[${i}]}" "${missing_pkgs[${i}]}" "${assert_msg}[${i}]" done -fix_pkgs=( $("${bazel}" run "//:bzlformat_missing_pkgs_fix") ) +fix_pkgs=() +while IFS=$'\n' read -r line; do fix_pkgs+=("$line"); done < <( + "${bazel}" run "//:bzlformat_missing_pkgs_fix" +) assert_msg="Update with no missing packages" -# Note: The expected array purposefully does not quote the message as the fix_pkgs array +# Note: The expected array purposefully does not quote the message as the fix_pkgs array # will parse each space-separated item. -expected_array=(No missing package updates were found.) +expected_array=("No missing package updates were found.") assert_equal ${#expected_array[@]} ${#fix_pkgs[@]} "${assert_msg}" for (( i = 0; i < ${#expected_array[@]}; i++ )); do assert_equal "${expected_array[${i}]}" "${fix_pkgs[${i}]}" "${assert_msg}[${i}]" From 892c45b80b32dd1e7bc0cc13ba0233e497ada75a Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 08:58:52 -0600 Subject: [PATCH 14/73] Address ShellCheck issues in normalize_pkg_test.sh. --- .../missing_pkgs_tests/common_tests/normalize_pkg_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/common_tests/normalize_pkg_test.sh b/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/common_tests/normalize_pkg_test.sh index 28fee13b..712c3a97 100755 --- a/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/common_tests/normalize_pkg_test.sh +++ b/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/common_tests/normalize_pkg_test.sh @@ -12,7 +12,9 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ # --- end runfiles.bash initialization v3 --- assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" +# shellcheck source=SCRIPTDIR/../../../../../shlib/lib/assertions.sh source "${assertions_lib}" +# shellcheck source=SCRIPTDIR/../../../../../bzlformat/tools/missing_pkgs/common.sh source "$(rlocation cgrindel_bazel_starlib/bzlformat/tools/missing_pkgs/common.sh)" assert_equal "//foo/bar" "$(normalize_pkg "foo/bar")" From 3c0cc9e63639f2bf2ed2cbd05d1322c81d88f098 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:02:35 -0600 Subject: [PATCH 15/73] Address ShellCheck issues in buildifier.sh. --- bzlformat/tools/buildifier.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bzlformat/tools/buildifier.sh b/bzlformat/tools/buildifier.sh index 32d557bb..878d2e23 100755 --- a/bzlformat/tools/buildifier.sh +++ b/bzlformat/tools/buildifier.sh @@ -16,18 +16,19 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" arrays_sh_location=cgrindel_bazel_starlib/shlib/lib/arrays.sh arrays_sh="$(rlocation "${arrays_sh_location}")" || \ (echo >&2 "Failed to locate ${arrays_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/arrays.sh source "${arrays_sh}" buildifier_location=buildifier_prebuilt/buildifier/buildifier buildifier="$(rlocation "${buildifier_location}")" || \ (echo >&2 "Failed to locate ${buildifier_location}" && exit 1) - # MARK - Process Args # Lint Mode @@ -40,8 +41,9 @@ lint_mode="off" warnings="all" get_usage() { - local utility="$(basename "${BASH_SOURCE[0]}")" - echo "$(cat <<-EOF + local utility + utility="$(basename "${BASH_SOURCE[0]}")" + cat <<-EOF Executes buildifier for a Starlark file and writes the resulting output to a file. Usage: @@ -53,7 +55,6 @@ Options: A path to a Starlark file A path where to write the output from buildifier EOF - )" } args=() @@ -61,7 +62,6 @@ while (("$#")); do case "${1}" in "--help") show_usage - exit 0 ;; "--lint_mode") lint_mode="${2}" @@ -81,9 +81,9 @@ while (("$#")); do esac done -[[ ${#args[@]} < 1 ]] && usage_error "Expected a path to a Starlark file." +[[ ${#args[@]} -lt 1 ]] && usage_error "Expected a path to a Starlark file." bzl_path="${args[0]}" -[[ ${#args[@]} > 1 ]] && out_path="${args[1]}" +[[ ${#args[@]} -gt 1 ]] && out_path="${args[1]}" contains_item "${lint_mode}" "${lint_modes[@]}" || \ usage_error "Invalid lint_mode (${lint_mode}). Expected to be one of the following: $( join_by ", " "${lint_modes[@]}" )." @@ -95,7 +95,7 @@ exec_buildifier() { local bzl_path="${1}" shift 1 local buildifier_cmd=( "${buildifier}" "--path=${bzl_path}" ) - [[ ${#} > 0 ]] && buildifier_cmd+=( "${@}" ) + [[ ${#} -gt 0 ]] && buildifier_cmd+=( "${@}" ) "${buildifier_cmd[@]}" } From 1d3b067f30e4babe1c19d3877f35aaf239656913 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:12:53 -0600 Subject: [PATCH 16/73] Address ShellCheck issues in find.sh. --- bzlformat/tools/missing_pkgs/find.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bzlformat/tools/missing_pkgs/find.sh b/bzlformat/tools/missing_pkgs/find.sh index 4e91ddd4..c09aa74f 100755 --- a/bzlformat/tools/missing_pkgs/find.sh +++ b/bzlformat/tools/missing_pkgs/find.sh @@ -12,11 +12,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ # --- end runfiles.bash initialization v3 --- arrays_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/arrays.sh)" +# shellcheck source=SCRIPTDIR/../../../shlib/lib/arrays.sh source "${arrays_lib}" common_sh_location=cgrindel_bazel_starlib/bzlformat/tools/missing_pkgs/common.sh common_sh="$(rlocation "${common_sh_location}")" || \ (echo >&2 "Failed to locate ${common_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/common.sh source "${common_sh}" query_for_pkgs() { @@ -49,8 +51,14 @@ done cd "${BUILD_WORKSPACE_DIRECTORY}" # The output `package` appears to sort the results -all_pkgs=( $(query_for_pkgs //...) ) -pkgs_with_format=( $(query_for_pkgs 'kind(bzlformat_format, //...)') ) +all_pkgs=() +while IFS=$'\n' read -r line; do all_pkgs+=("$line"); done < <( + query_for_pkgs //... +) +pkgs_with_format=() +while IFS=$'\n' read -r line; do pkgs_with_format+=("$line"); done < <( + query_for_pkgs 'kind(bzlformat_format, //...)' +) pkgs_missing_format=() for pkg in "${all_pkgs[@]}" ; do @@ -59,7 +67,7 @@ for pkg in "${all_pkgs[@]}" ; do fi done -if [[ ${#pkgs_missing_format[@]} > 0 ]]; then +if [[ ${#pkgs_missing_format[@]} -gt 0 ]]; then # Output the missing packages. print_by_line "${pkgs_missing_format[@]:-}" From 8f04e2446ce115e65f741c0111e4bbb15968ec7a Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:19:42 -0600 Subject: [PATCH 17/73] Address ShellCheck issues in fix.sh. --- bzlformat/tools/missing_pkgs/fix.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bzlformat/tools/missing_pkgs/fix.sh b/bzlformat/tools/missing_pkgs/fix.sh index 28154f9e..0236c67c 100755 --- a/bzlformat/tools/missing_pkgs/fix.sh +++ b/bzlformat/tools/missing_pkgs/fix.sh @@ -14,13 +14,16 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ # --- end runfiles.bash initialization v3 --- arrays_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/arrays.sh)" +# shellcheck source=SCRIPTDIR/../../../shlib/lib/arrays.sh source "${arrays_lib}" common_sh_location=cgrindel_bazel_starlib/bzlformat/tools/missing_pkgs/common.sh common_sh="$(rlocation "${common_sh_location}")" || \ (echo >&2 "Failed to locate ${common_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/common.sh source "${common_sh}" +# shellcheck source=SCRIPTDIR/find.sh find_missing_pkgs_bin="$(rlocation cgrindel_bazel_starlib/bzlformat/tools/missing_pkgs/find.sh)" buildozer_location=buildifier_prebuilt/buildozer/buildozer @@ -32,7 +35,7 @@ args=() while (("$#")); do case "${1}" in "--exclude") - exclude_pkgs+=( $(normalize_pkg "${2}") ) + exclude_pkgs+=( "$(normalize_pkg "${2}")" ) shift 2 ;; *) @@ -49,10 +52,13 @@ find_args=() for pkg in "${exclude_pkgs[@]:-}" ; do find_args+=(--exclude "${pkg}") done -missing_pkgs=( $(. "${find_missing_pkgs_bin}" "${find_args[@]:-}") ) +missing_pkgs=() +while IFS=$'\n' read -r line; do missing_pkgs+=("$line"); done < <( + "${find_missing_pkgs_bin}" "${find_args[@]:-}" +) # If no missing packages, we are done. -[[ ${#missing_pkgs[@]} == 0 ]] && echo "No missing package updates were found." && exit +[[ ${#missing_pkgs[@]} -eq 0 ]] && echo "No missing package updates were found." && exit echo "Updating the following packages:" for pkg in "${missing_pkgs[@]}" ; do From 282d23fdf8989ee9272cb58d78c9df79830daed4 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:25:02 -0600 Subject: [PATCH 18/73] Fix missing main_branch in generate_gh_changelog.sh. --- bzlrelease/tools/generate_gh_changelog.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bzlrelease/tools/generate_gh_changelog.sh b/bzlrelease/tools/generate_gh_changelog.sh index f115225b..de71a32c 100755 --- a/bzlrelease/tools/generate_gh_changelog.sh +++ b/bzlrelease/tools/generate_gh_changelog.sh @@ -42,6 +42,7 @@ is_installed git || fail "Could not find git." # MARK - Process Arguments +main_branch=main args=() while (("$#")); do case "${1}" in From 1ff3e96af9bdcc826cc2b6cf9026acc2cba13b39 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:27:26 -0600 Subject: [PATCH 19/73] Address ShellCheck issues in create_release.sh. --- bzlrelease/tools/create_release.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bzlrelease/tools/create_release.sh b/bzlrelease/tools/create_release.sh index 0bd6a7d0..19aaa22e 100755 --- a/bzlrelease/tools/create_release.sh +++ b/bzlrelease/tools/create_release.sh @@ -16,21 +16,25 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/env.sh source "${env_sh}" git_sh_location=cgrindel_bazel_starlib/shlib/lib/git.sh git_sh="$(rlocation "${git_sh_location}")" || \ (echo >&2 "Failed to locate ${git_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/git.sh source "${git_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/github.sh source "${github_sh}" @@ -42,8 +46,9 @@ is_installed gh || fail "Could not find Github CLI (gh)." # MARK - Usage get_usage() { - local utility="$(basename "${BASH_SOURCE[0]}")" - echo "$(cat <<-EOF + local utility + utility="$(basename "${BASH_SOURCE[0]}")" + cat <<-EOF Execute a Github Action workflow to create a relase with the specified tag. Usage: @@ -59,7 +64,6 @@ Options: --reset_tag If specified and if a release does not exist for the tag, the existing tag will be deleted and a new one created. EOF - )" } @@ -72,7 +76,6 @@ while (("$#")); do case "${1}" in "--help") show_usage - exit 0 ;; --workflow) workflow_name="${2}" From bd82194b1431d600a77c69a8af6ed36fff96a903 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:29:57 -0600 Subject: [PATCH 20/73] Address ShellCheck issues in create_release_tag.sh. --- bzlrelease/tools/create_release_tag.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bzlrelease/tools/create_release_tag.sh b/bzlrelease/tools/create_release_tag.sh index a760f462..c34795e4 100755 --- a/bzlrelease/tools/create_release_tag.sh +++ b/bzlrelease/tools/create_release_tag.sh @@ -16,21 +16,25 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/env.sh source "${env_sh}" git_sh_location=cgrindel_bazel_starlib/shlib/lib/git.sh git_sh="$(rlocation "${git_sh_location}")" || \ (echo >&2 "Failed to locate ${git_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/git.sh source "${git_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/github.sh source "${github_sh}" @@ -44,24 +48,24 @@ is_installed git || fail "Could not find git." "${required_software}" # MARK - Process Args get_usage() { - local utility="$(basename "${BASH_SOURCE[0]}")" - echo "$(cat <<-EOF + local utility + utility="$(basename "${BASH_SOURCE[0]}")" + cat <<-EOF Create a release tag and push it to the remote. Usage: ${utility} [--remote ] [--branch ] EOF - )" } reset_tag=false +main_branch=main args=() while (("$#")); do case "${1}" in "--help") show_usage - exit 0 ;; --remote) remote="${2}" @@ -108,13 +112,12 @@ if git_tag_exists "${tag}"; then echo "The tag (${tag}) exists locally, but does not exist on origin." else commit="$( get_git_commit_hash "${remote}/${main_branch}" )" - echo "$(cat <<-EOF + cat <<-EOF Creating release tag. Tag: ${tag} Branch: ${main_branch} Commit: ${commit} EOF -)" create_git_release_tag "${tag}" "${commit}" fi From 4fac13549da0cb74dd21ae971437e386187722cb Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:34:19 -0600 Subject: [PATCH 21/73] Fixed SC issue missed in git.sh. --- shlib/lib/git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shlib/lib/git.sh b/shlib/lib/git.sh index 6778da74..9a4f1e46 100644 --- a/shlib/lib/git.sh +++ b/shlib/lib/git.sh @@ -22,7 +22,7 @@ fetch_latest_from_git_remote() { local remote="${1:-}" local branch="${2:-}" fetch_cmd=(git fetch) - if [[ ! -z "${remote:-}" ]]; then + if [[ -n "${remote:-}" ]]; then fetch_cmd+=( "${remote}" ) [[ -z "${branch:-}" ]] || fetch_cmd+=( "${branch}" ) fi From 767046dc9938f929ca88795d1756df0b199410ea Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:36:54 -0600 Subject: [PATCH 22/73] Address ShellCheck issues in generate_gh_changelog.sh. --- bzlrelease/tools/generate_gh_changelog.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bzlrelease/tools/generate_gh_changelog.sh b/bzlrelease/tools/generate_gh_changelog.sh index de71a32c..0440dad8 100755 --- a/bzlrelease/tools/generate_gh_changelog.sh +++ b/bzlrelease/tools/generate_gh_changelog.sh @@ -16,21 +16,25 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/env.sh source "${env_sh}" git_sh_location=cgrindel_bazel_starlib/shlib/lib/git.sh git_sh="$(rlocation "${git_sh_location}")" || \ (echo >&2 "Failed to locate ${git_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/git.sh source "${git_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/github.sh source "${github_sh}" @@ -66,7 +70,6 @@ tag_name="${args[0]}" # MARK - Generate the changelog. -starting_dir="${PWD}" cd "${BUILD_WORKSPACE_DIRECTORY}" repo_url="$( get_git_remote_url )" @@ -74,6 +77,7 @@ is_github_repo_url "${repo_url}" || \ fail "The git repository's remote URL does not appear to be a Github URL. ${repo_url}" # Fetch the latest from origin +# shellcheck disable=SC2119 fetch_latest_from_git_remote # Construct the args for generating the changelog. From 3efb4507ea62e0b60958f7ea4e38cced3f094208 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:38:36 -0600 Subject: [PATCH 23/73] Address ShellCheck issues in generate_git_archive.sh. --- bzlrelease/tools/generate_git_archive.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bzlrelease/tools/generate_git_archive.sh b/bzlrelease/tools/generate_git_archive.sh index 7e281077..08299234 100755 --- a/bzlrelease/tools/generate_git_archive.sh +++ b/bzlrelease/tools/generate_git_archive.sh @@ -23,21 +23,25 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/env.sh source "${env_sh}" git_sh_location=cgrindel_bazel_starlib/shlib/lib/git.sh git_sh="$(rlocation "${git_sh_location}")" || \ (echo >&2 "Failed to locate ${git_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/git.sh source "${git_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/github.sh source "${github_sh}" is_installed git || fail "This utility requires git to be installed and in the path." @@ -90,10 +94,10 @@ done # MARK - Main -starting_dir="${PWD}" cd "${BUILD_WORKSPACE_DIRECTORY}" # Fetch the latest from origin +# shellcheck disable=SC2119 fetch_latest_from_git_remote if [[ -z "${prefix:-}" ]]; then From 6d415b85c8e32b4183eabed0dfeb15875b816c15 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:39:51 -0600 Subject: [PATCH 24/73] Address ShellCheck issues in generate_module_snippet.sh. --- bzlrelease/tools/generate_module_snippet.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bzlrelease/tools/generate_module_snippet.sh b/bzlrelease/tools/generate_module_snippet.sh index 5b93611e..358d34ce 100755 --- a/bzlrelease/tools/generate_module_snippet.sh +++ b/bzlrelease/tools/generate_module_snippet.sh @@ -19,6 +19,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" # MARK - Process Args From cf877fe2c0cf5b650077b14e1ca1f3bb7535f5c3 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:42:02 -0600 Subject: [PATCH 25/73] Address ShellCheck issues in generate_release_notes.sh. --- bzlrelease/tools/generate_release_notes.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bzlrelease/tools/generate_release_notes.sh b/bzlrelease/tools/generate_release_notes.sh index a47ec6b5..ca17402b 100755 --- a/bzlrelease/tools/generate_release_notes.sh +++ b/bzlrelease/tools/generate_release_notes.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" generate_gh_changelog_sh_location=cgrindel_bazel_starlib/bzlrelease/tools/generate_gh_changelog.sh @@ -61,7 +62,7 @@ while (("$#")); do esac done -[[ ${#args[@]} == 0 ]] && fail "A tag name for the release must be specified." +[[ ${#args[@]} -eq 0 ]] && fail "A tag name for the release must be specified." tag_name="${args[0]}" if [[ -z "${generate_workspace_snippet:-}" ]] && [[ -z "${generate_module_snippet:-}" ]]; then From adaceeb055d6d2358caf314b864cfda57c2274fc Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:43:24 -0600 Subject: [PATCH 26/73] Address ShellCheck issues in generate_sha256.sh. --- bzlrelease/tools/generate_sha256.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bzlrelease/tools/generate_sha256.sh b/bzlrelease/tools/generate_sha256.sh index 53715f0e..bd3164fd 100755 --- a/bzlrelease/tools/generate_sha256.sh +++ b/bzlrelease/tools/generate_sha256.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/env.sh source "${env_sh}" From 9ef6521a34eb4b86fd55f5ea03225a607cf7777f Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:46:55 -0600 Subject: [PATCH 27/73] Address ShellCheck issues in generate_workspace_snippet.sh. --- bzlrelease/tools/generate_workspace_snippet.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bzlrelease/tools/generate_workspace_snippet.sh b/bzlrelease/tools/generate_workspace_snippet.sh index cb9907d4..4819adeb 100755 --- a/bzlrelease/tools/generate_workspace_snippet.sh +++ b/bzlrelease/tools/generate_workspace_snippet.sh @@ -26,16 +26,19 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" git_sh_location=cgrindel_bazel_starlib/shlib/lib/git.sh git_sh="$(rlocation "${git_sh_location}")" || \ (echo >&2 "Failed to locate ${git_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/git.sh source "${git_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/github.sh source "${github_sh}" generate_git_archive_sh_location=cgrindel_bazel_starlib/bzlrelease/tools/generate_git_archive.sh @@ -120,12 +123,14 @@ while (("$#")); do esac done -[[ ${#args[@]} -gt 0 ]] && fail "Received unexpected arguments: ${args[@]}" +[[ ${#args[@]} -gt 0 ]] && fail "Received unexpected arguments:" "${args[@]}" [[ -z "${tag:-}" ]] && fail "Expected a tag value." +# shellcheck disable=SC2016 [[ "${add_github_src_archive_url}" == true ]] && \ url_templates+=( 'http://github.com/${owner}/${repo}/archive/${tag}.tar.gz' ) +# shellcheck disable=SC2016 [[ "${add_github_release_archive_url}" == true ]] && \ url_templates+=( 'https://github.com/${owner}/${repo}/releases/download/${tag}/${repo}.${tag}.tar.gz' ) [[ ${#url_templates[@]} -gt 0 ]] || fail "Expected one ore more url templates." From 4c7a4e89993024ac861d7e3af0ad4ba860d91941 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 09:49:08 -0600 Subject: [PATCH 28/73] Address ShellCheck issues in update_readme.sh. --- bzlrelease/tools/update_readme.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bzlrelease/tools/update_readme.sh b/bzlrelease/tools/update_readme.sh index f8fe7a44..934ecbf4 100755 --- a/bzlrelease/tools/update_readme.sh +++ b/bzlrelease/tools/update_readme.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" update_markdown_doc_sh_location=cgrindel_bazel_starlib/markdown/tools/update_markdown_doc.sh @@ -30,10 +31,6 @@ starting_dir="${PWD}" args=() while (("$#")); do case "${1}" in - "--output") - output_path="${2}" - shift 2 - ;; "--generate_workspace_snippet") # If the input path is not absolute, then resolve it to be relative to # the starting directory. We do this before we starting changing From bf447b252d426c028594c14c1534bb3df1a07aca Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:13:58 -0600 Subject: [PATCH 29/73] Add rlocation back to files.sh. --- shlib/lib/BUILD.bazel | 5 ++++- shlib/lib/files.sh | 26 ++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/shlib/lib/BUILD.bazel b/shlib/lib/BUILD.bazel index 23e6d72e..ff919836 100644 --- a/shlib/lib/BUILD.bazel +++ b/shlib/lib/BUILD.bazel @@ -23,7 +23,10 @@ sh_library( sh_library( name = "files", srcs = ["files.sh"], - deps = [":paths"], + deps = [ + ":paths", + "@bazel_tools//tools/bash/runfiles", + ], ) sh_library( diff --git a/shlib/lib/files.sh b/shlib/lib/files.sh index 3378a8c5..1ca8c3b2 100644 --- a/shlib/lib/files.sh +++ b/shlib/lib/files.sh @@ -1,13 +1,31 @@ #!/usr/bin/env bash -# This is used to determine if the library has been loaded -cgrindel_bazel_shlib_lib_files_loaded() { return; } +# Since we are in a library, check if rlocation has been defined yet. +if [[ $(type -t rlocation) != function ]]; then + # --- begin runfiles.bash initialization v3 --- + # Copy-pasted from the Bazel Bash runfiles library v3. + set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash + source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e + # --- end runfiles.bash initialization v3 --- +fi if [[ $(type -t cgrindel_bazel_shlib_lib_paths_loaded) != function ]]; then - # shellcheck source=SCRIPTDIR/paths.sh - source "shlib/lib/paths.sh" + paths_sh_location=cgrindel_bazel_starlib/shlib/lib/paths.sh + paths_sh="$(rlocation "${paths_sh_location}")" || \ + (echo >&2 "Failed to locate ${paths_sh_location}" && exit 1) + # shellcheck disable=SC1090 # external source + source "${paths_sh}" fi +# This is used to determine if the library has been loaded +cgrindel_bazel_shlib_lib_files_loaded() { return; } + + # Recursively searches for a file starting from the current directory up to the root of the filesystem. # # Flags: From 4860b505e3015196ac702ce5940861277efb79ee Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:22:45 -0600 Subject: [PATCH 30/73] Address ShellCheck issues in tidy.sh and check_tidy.sh. --- bzltidy/private/check_tidy.sh | 1 - bzltidy/private/tidy.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/bzltidy/private/check_tidy.sh b/bzltidy/private/check_tidy.sh index e21edcea..86245082 100755 --- a/bzltidy/private/check_tidy.sh +++ b/bzltidy/private/check_tidy.sh @@ -82,7 +82,6 @@ while (("$#")); do case "${1}" in "--help") show_usage - exit 0 ;; --*) usage_error "Unrecognized option. ${1}" diff --git a/bzltidy/private/tidy.sh b/bzltidy/private/tidy.sh index a5bb4d51..7b6e9c69 100755 --- a/bzltidy/private/tidy.sh +++ b/bzltidy/private/tidy.sh @@ -77,7 +77,6 @@ while (("$#")); do case "${1}" in "--help") show_usage - exit 0 ;; --*) usage_error "Unrecognized option. ${1}" From 1d4f05f223ebfe7036d8cae85ad81c6e0a24b5d0 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:28:29 -0600 Subject: [PATCH 31/73] Address ShellCheck issues in examples/bzlformat/simple_test.sh. --- examples/bzlformat/simple_test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/bzlformat/simple_test.sh b/examples/bzlformat/simple_test.sh index faf4ca75..00cfc5ba 100755 --- a/examples/bzlformat/simple_test.sh +++ b/examples/bzlformat/simple_test.sh @@ -20,16 +20,19 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/assertions.sh source "${assertions_sh}" paths_sh_location=cgrindel_bazel_starlib/shlib/lib/paths.sh paths_sh="$(rlocation "${paths_sh_location}")" || \ (echo >&2 "Failed to locate ${paths_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/paths.sh source "${paths_sh}" messages_sh_location=cgrindel_bazel_starlib/shlib/lib/messages.sh messages_sh="$(rlocation "${messages_sh_location}")" || \ (echo >&2 "Failed to locate ${messages_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/messages.sh source "${messages_sh}" create_scratch_dir_sh_location=rules_bazel_integration_test/tools/create_scratch_dir.sh From af2c1b1f69a9741acc512791ada7327c23fe130b Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:34:23 -0600 Subject: [PATCH 32/73] Address ShellCheck issues in update_markdown_doc.sh. --- markdown/tools/update_markdown_doc.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/markdown/tools/update_markdown_doc.sh b/markdown/tools/update_markdown_doc.sh index e353d2ec..9e8d3723 100755 --- a/markdown/tools/update_markdown_doc.sh +++ b/markdown/tools/update_markdown_doc.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" @@ -55,7 +56,7 @@ done [[ -z "${update_path:-}" ]] && fail "No update file was specified." -([[ -z "${marker_begin:-}" ]] || [[ -z "${marker_end:-}" ]]) && \ +{ [[ -z "${marker_begin:-}" ]] || [[ -z "${marker_end:-}" ]]; } && \ fail "No markers were specified." [[ ${#args[@]} != 2 ]] && fail "Expected exactly two files: input and output." From a7cac02062419c90f6269c12a26df482a7f47584 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:35:25 -0600 Subject: [PATCH 33/73] Address ShellCheck issues in update_markdown_toc.sh. --- markdown/tools/update_markdown_toc.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/markdown/tools/update_markdown_toc.sh b/markdown/tools/update_markdown_toc.sh index ab4ee541..990a0f12 100755 --- a/markdown/tools/update_markdown_toc.sh +++ b/markdown/tools/update_markdown_toc.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../shlib/lib/fail.sh source "${fail_sh}" update_markdown_doc_sh_location=cgrindel_bazel_starlib/markdown/tools/update_markdown_doc.sh From ed2a60a54a0e3cdf0510e4860fb366ee3ed79c70 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:41:07 -0600 Subject: [PATCH 34/73] Address ShellCheck issues in generate_release_notes_tests.sh. --- .../generate_release_notes_test.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/bzlrelease_tests/rules_tests/generate_release_notes_tests/generate_release_notes_test.sh b/tests/bzlrelease_tests/rules_tests/generate_release_notes_tests/generate_release_notes_test.sh index 873d0791..49b6c7e9 100755 --- a/tests/bzlrelease_tests/rules_tests/generate_release_notes_tests/generate_release_notes_test.sh +++ b/tests/bzlrelease_tests/rules_tests/generate_release_notes_tests/generate_release_notes_test.sh @@ -11,8 +11,11 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e # --- end runfiles.bash initialization v3 --- -assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" -source "${assertions_lib}" +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh +source "${assertions_sh}" setup_git_repo_sh_location=cgrindel_bazel_starlib/tests/setup_git_repo.sh setup_git_repo_sh="$(rlocation "${setup_git_repo_sh_location}")" || \ @@ -28,6 +31,7 @@ generate_release_notes_with_workspace_name_sh="$(rlocation "${generate_release_n # MARK - Setup +# shellcheck source=SCRIPTDIR/../../../setup_git_repo.sh source "${setup_git_repo_sh}" From 88630335f885e22a331f4d06e399bc4d41402af0 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:43:18 -0600 Subject: [PATCH 35/73] Update ShellCheck issues in generate_workspace_snippet_tests.sh, archive_test.sh, update_readme_test.sh. --- .../generate_workspace_snippet_test.sh | 2 ++ .../rules_tests/release_artifact_tests/archive_test.sh | 1 + .../rules_tests/update_readme_tests/update_readme_test.sh | 2 ++ 3 files changed, 5 insertions(+) diff --git a/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/generate_workspace_snippet_test.sh b/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/generate_workspace_snippet_test.sh index 1a7f1bb0..d5abc2db 100755 --- a/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/generate_workspace_snippet_test.sh +++ b/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/generate_workspace_snippet_test.sh @@ -14,6 +14,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" setup_git_repo_sh_location=cgrindel_bazel_starlib/tests/setup_git_repo.sh @@ -38,6 +39,7 @@ archive_sha256="$(rlocation "${archive_sha256_location}")" || \ # MARK - Setup +# shellcheck source=SCRIPTDIR/../../../setup_git_repo.sh source "${setup_git_repo_sh}" # MARK - Test diff --git a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh index 404e57a8..47ac090f 100755 --- a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh +++ b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" archive_tar_gz_location=cgrindel_bazel_starlib/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive.tar.gz diff --git a/tests/bzlrelease_tests/rules_tests/update_readme_tests/update_readme_test.sh b/tests/bzlrelease_tests/rules_tests/update_readme_tests/update_readme_test.sh index da6f50a7..15f2f471 100755 --- a/tests/bzlrelease_tests/rules_tests/update_readme_tests/update_readme_test.sh +++ b/tests/bzlrelease_tests/rules_tests/update_readme_tests/update_readme_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" setup_git_repo_sh_location=cgrindel_bazel_starlib/tests/setup_git_repo.sh @@ -29,6 +30,7 @@ update_readme_sh="$(rlocation "${update_readme_sh_location}")" || \ # MARK - Setup +# shellcheck source=SCRIPTDIR/../../../setup_git_repo.sh source "${setup_git_repo_sh}" readme_content="$(cat <<-EOF From 78b09d97e460b3af3f3bdfc110d2fcb05db12633 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:55:56 -0600 Subject: [PATCH 36/73] Address ShellCheck issues in generate_gh_changelog_test.sh. --- .../tools_tests/generate_gh_changelog_test.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/bzlrelease_tests/tools_tests/generate_gh_changelog_test.sh b/tests/bzlrelease_tests/tools_tests/generate_gh_changelog_test.sh index 56b143ed..ccee4839 100755 --- a/tests/bzlrelease_tests/tools_tests/generate_gh_changelog_test.sh +++ b/tests/bzlrelease_tests/tools_tests/generate_gh_changelog_test.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/env.sh source "${env_sh}" generate_gh_changelog_sh_location=cgrindel_bazel_starlib/bzlrelease/tools/generate_gh_changelog.sh @@ -35,6 +37,7 @@ is_installed git || fail "Could not find git." # MARK - Setup +# shellcheck source=SCRIPTDIR/../../setup_git_repo.sh source "${setup_git_repo_sh}" cd "${repo_dir}" @@ -44,7 +47,8 @@ cd "${repo_dir}" tag_name="v0.1.1" prev_tag_name="v0.1.0" result="$( "${generate_gh_changelog_sh}" --previous_tag_name "${prev_tag_name}" "${tag_name}" )" -[[ "${result}" =~ "**Full Changelog**: https://github.com/cgrindel/bazel-starlib/compare/v0.1.0...v0.1.1" ]] || \ +# [[ "${result}" =~ "**Full Changelog**: https://github.com/cgrindel/bazel-starlib/compare/v0.1.0...v0.1.1" ]] || \ +[[ "${result}" =~ \*\*Full\ Changelog\*\*:\ https://github.com/cgrindel/bazel-starlib/compare/v0\.1\.0\.\.\.v0\.1\.1 ]] || \ fail "Expected to find changelog URL for v0.1.0...v0.1.1. result: ${result}" From a40e755a33dad8ed0fe68efe91accdc60b76d86f Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:57:32 -0600 Subject: [PATCH 37/73] Address ShellCheck issues in generate_git_archive_test.sh. --- .../bzlrelease_tests/tools_tests/generate_git_archive_test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/bzlrelease_tests/tools_tests/generate_git_archive_test.sh b/tests/bzlrelease_tests/tools_tests/generate_git_archive_test.sh index 89ded188..1896e7e0 100755 --- a/tests/bzlrelease_tests/tools_tests/generate_git_archive_test.sh +++ b/tests/bzlrelease_tests/tools_tests/generate_git_archive_test.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/env.sh source "${env_sh}" setup_git_repo_sh_location=cgrindel_bazel_starlib/tests/setup_git_repo.sh @@ -39,6 +41,7 @@ is_installed git || fail "Could not find git." # MARK - Setup +# shellcheck source=SCRIPTDIR/../../setup_git_repo.sh source "${setup_git_repo_sh}" cd "${repo_dir}" From 97f71cc8a56169ee10b93768d49eb7773e70964f Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:58:25 -0600 Subject: [PATCH 38/73] Address ShellCheck issues in generate_module_snippet_test.sh. --- .../bzlrelease_tests/tools_tests/generate_module_snippet_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bzlrelease_tests/tools_tests/generate_module_snippet_test.sh b/tests/bzlrelease_tests/tools_tests/generate_module_snippet_test.sh index 77039e15..30023488 100755 --- a/tests/bzlrelease_tests/tools_tests/generate_module_snippet_test.sh +++ b/tests/bzlrelease_tests/tools_tests/generate_module_snippet_test.sh @@ -17,6 +17,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/assertions.sh source "${assertions_sh}" generate_module_snippet_sh_location=cgrindel_bazel_starlib/bzlrelease/tools/generate_module_snippet.sh From 53228a63b6fb0994239c96e4cb2733940bbe9da6 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 10:59:45 -0600 Subject: [PATCH 39/73] Address ShellCheck issues in generate_release_notes_test.sh. --- .../tools_tests/generate_release_notes_test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/bzlrelease_tests/tools_tests/generate_release_notes_test.sh b/tests/bzlrelease_tests/tools_tests/generate_release_notes_test.sh index bfcd89e3..0577a0be 100755 --- a/tests/bzlrelease_tests/tools_tests/generate_release_notes_test.sh +++ b/tests/bzlrelease_tests/tools_tests/generate_release_notes_test.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/env.sh source "${env_sh}" assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/assertions.sh source "${assertions_sh}" setup_git_repo_sh_location=cgrindel_bazel_starlib/tests/setup_git_repo.sh @@ -82,6 +84,7 @@ EOF chmod +x "${generate_workspace_snippet_sh}" +# shellcheck source=SCRIPTDIR/../../setup_git_repo.sh source "${setup_git_repo_sh}" cd "${repo_dir}" From a11b3431052564920a1c2766f23383f117cdf327 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:00:40 -0600 Subject: [PATCH 40/73] Address ShellCheck issues in generate_sha256_test.sh. --- tests/bzlrelease_tests/tools_tests/generate_sha256_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bzlrelease_tests/tools_tests/generate_sha256_test.sh b/tests/bzlrelease_tests/tools_tests/generate_sha256_test.sh index 92e39957..b51511c5 100755 --- a/tests/bzlrelease_tests/tools_tests/generate_sha256_test.sh +++ b/tests/bzlrelease_tests/tools_tests/generate_sha256_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/fail.sh source "${fail_sh}" generate_sha256_sh_location=cgrindel_bazel_starlib/bzlrelease/tools/generate_sha256.sh From 6ee71207418a6957a4c13d692f91644579e2e550 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:04:24 -0600 Subject: [PATCH 41/73] Address ShellCheck issues in generate_workspace_snippet_test.sh. --- bzlrelease/tools/generate_workspace_snippet.sh | 2 +- .../tools_tests/generate_workspace_snippet_test.sh | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bzlrelease/tools/generate_workspace_snippet.sh b/bzlrelease/tools/generate_workspace_snippet.sh index 4819adeb..82790eaa 100755 --- a/bzlrelease/tools/generate_workspace_snippet.sh +++ b/bzlrelease/tools/generate_workspace_snippet.sh @@ -133,7 +133,7 @@ done # shellcheck disable=SC2016 [[ "${add_github_release_archive_url}" == true ]] && \ url_templates+=( 'https://github.com/${owner}/${repo}/releases/download/${tag}/${repo}.${tag}.tar.gz' ) -[[ ${#url_templates[@]} -gt 0 ]] || fail "Expected one ore more url templates." +[[ ${#url_templates[@]} -gt 0 ]] || fail "Expected one or more url templates." # MARK - Ensure that we have a SHA256 value diff --git a/tests/bzlrelease_tests/tools_tests/generate_workspace_snippet_test.sh b/tests/bzlrelease_tests/tools_tests/generate_workspace_snippet_test.sh index 5eac2800..f228bf23 100755 --- a/tests/bzlrelease_tests/tools_tests/generate_workspace_snippet_test.sh +++ b/tests/bzlrelease_tests/tools_tests/generate_workspace_snippet_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/fail.sh source "${fail_sh}" setup_git_repo_sh_location=cgrindel_bazel_starlib/tests/setup_git_repo.sh @@ -32,6 +33,7 @@ workspace_snippet_tmpl="$(rlocation "${workspace_snippet_tmpl_location}")" || \ # MARK - Setup +# shellcheck source=SCRIPTDIR/../../setup_git_repo.sh source "${setup_git_repo_sh}" cd "${repo_dir}" @@ -119,7 +121,9 @@ actual_snippet="$(< "${output_path}")" owner=acme repo=rules_fun +# shellcheck disable=SC2016 # Template string url1='http://github.com/${owner}/${repo}/releases/download/${tag}/${repo}-${tag:1}.tar.gz' +# shellcheck disable=SC2016 # Template string url2='http://mirror.bazel.build/github.com/${owner}/${repo}/releases/download/${tag}/${repo}-${tag:1}.tar.gz' strip_prefix="rules_fun-1.2.3" @@ -163,7 +167,7 @@ actual_snippet="$( [[ "${actual_snippet}" =~ load.*http_archive ]] || \ fail "Did not find load statement from the template." -[[ "${actual_snippet}" =~ 'http_archive(' ]] || \ +[[ "${actual_snippet}" =~ http_archive\( ]] || \ fail "Did not find http_archive statement from the utility." @@ -174,7 +178,7 @@ err_output="$( --sha256 "${sha256}" \ 2>&1 || true )" -[[ "${err_output}" =~ "Expected a tag value." ]] || fail "Missing tag failure." +[[ "${err_output}" =~ Expected\ a\ tag\ value\. ]] || fail "Missing tag failure." err_output="$( "${generate_workspace_snippet_sh}" \ @@ -183,5 +187,5 @@ err_output="$( --no_github_source_archive_url \ 2>&1 || true )" -[[ "${err_output}" =~ "Expected one ore more url templates." ]] || fail "Missing url template failure." +[[ "${err_output}" =~ Expected\ one\ or\ more\ url\ templates\. ]] || fail "Missing url template failure." From cde8a6865859ae67d3a37f5559daa0eed5ca743c Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:05:43 -0600 Subject: [PATCH 42/73] Address ShellCheck issues in update_readme_test.sh. --- tests/bzlrelease_tests/tools_tests/update_readme_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bzlrelease_tests/tools_tests/update_readme_test.sh b/tests/bzlrelease_tests/tools_tests/update_readme_test.sh index 0916bf57..e4dcd4a1 100755 --- a/tests/bzlrelease_tests/tools_tests/update_readme_test.sh +++ b/tests/bzlrelease_tests/tools_tests/update_readme_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/assertions.sh source "${assertions_sh}" update_readme_sh_location=cgrindel_bazel_starlib/bzlrelease/tools/update_readme.sh From 1a1ff11ce881e6defac1d2f5d1cac1065f8a1eb6 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:07:23 -0600 Subject: [PATCH 43/73] Address ShellCheck issues in update_markdown_doc_test.sh. --- tests/markdown_tests/tools_tests/update_markdown_doc_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/markdown_tests/tools_tests/update_markdown_doc_test.sh b/tests/markdown_tests/tools_tests/update_markdown_doc_test.sh index bf403a45..6193e98d 100755 --- a/tests/markdown_tests/tools_tests/update_markdown_doc_test.sh +++ b/tests/markdown_tests/tools_tests/update_markdown_doc_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/assertions.sh source "${assertions_sh}" update_markdown_doc_sh_location=cgrindel_bazel_starlib/markdown/tools/update_markdown_doc.sh From 7a69fc1f2d2a4807851756425f203f81f64aa81d Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:08:14 -0600 Subject: [PATCH 44/73] Address ShellCheck issues in update_markdown_toc_test.sh. --- tests/markdown_tests/tools_tests/update_markdown_toc_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/markdown_tests/tools_tests/update_markdown_toc_test.sh b/tests/markdown_tests/tools_tests/update_markdown_toc_test.sh index bc282b03..dd7b7123 100755 --- a/tests/markdown_tests/tools_tests/update_markdown_toc_test.sh +++ b/tests/markdown_tests/tools_tests/update_markdown_toc_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../shlib/lib/assertions.sh source "${assertions_sh}" update_markdown_toc_sh_location=cgrindel_bazel_starlib/markdown/tools/update_markdown_toc.sh From bc19071be00f54b3cb4be4b3bc93684e6dc296f4 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:10:18 -0600 Subject: [PATCH 45/73] Address ShellCheck issues in contains_item_sorted_test.sh. --- .../arrays_tests/contains_item_sorted_test.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/shlib_tests/lib_tests/arrays_tests/contains_item_sorted_test.sh b/tests/shlib_tests/lib_tests/arrays_tests/contains_item_sorted_test.sh index 0244f5d1..25e0dd3f 100755 --- a/tests/shlib_tests/lib_tests/arrays_tests/contains_item_sorted_test.sh +++ b/tests/shlib_tests/lib_tests/arrays_tests/contains_item_sorted_test.sh @@ -11,11 +11,17 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e # --- end runfiles.bash initialization v3 --- -assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" -source "${assertions_lib}" - -arrays_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/arrays.sh)" -source "${arrays_lib}" +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh +source "${assertions_sh}" + +arrays_sh_location=cgrindel_bazel_starlib/shlib/lib/arrays.sh +arrays_sh="$(rlocation "${arrays_sh_location}")" || \ + (echo >&2 "Failed to locate ${arrays_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/arrays.sh +source "${arrays_sh}" # MARK - Even Numbered Array From 72550e9bf92b2456c7b1189f90f10a948e43c969 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:16:52 -0600 Subject: [PATCH 46/73] Address ShellCheck issues in contains_item_test.sh. --- .../lib_tests/arrays_tests/contains_item_test.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/shlib_tests/lib_tests/arrays_tests/contains_item_test.sh b/tests/shlib_tests/lib_tests/arrays_tests/contains_item_test.sh index 52e61071..d93e972c 100755 --- a/tests/shlib_tests/lib_tests/arrays_tests/contains_item_test.sh +++ b/tests/shlib_tests/lib_tests/arrays_tests/contains_item_test.sh @@ -11,11 +11,17 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e # --- end runfiles.bash initialization v3 --- -assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" -source "${assertions_lib}" - -arrays_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/arrays.sh)" -source "${arrays_lib}" +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh +source "${assertions_sh}" + +arrays_sh_location=cgrindel_bazel_starlib/shlib/lib/arrays.sh +arrays_sh="$(rlocation "${arrays_sh_location}")" || \ + (echo >&2 "Failed to locate ${arrays_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/arrays.sh +source "${arrays_sh}" # Unsorted array array=(z b y c x aa az) From dbf6ccdee81a556fb10c30a0b489a362e5d1c465 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:17:08 -0600 Subject: [PATCH 47/73] Address ShellCheck issues in double_quote_items_test.sh. --- shlib/lib/arrays.sh | 5 +--- .../arrays_tests/double_quote_items_test.sh | 25 ++++++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/shlib/lib/arrays.sh b/shlib/lib/arrays.sh index f9a5ae78..1cb9b479 100644 --- a/shlib/lib/arrays.sh +++ b/shlib/lib/arrays.sh @@ -76,15 +76,12 @@ join_by() { # stdout: The double quoted items separated by spaces. # stderr: None. double_quote_items() { - items=() while (("$#")); do - items+=( "\"${1}\"" ) + echo "\"${1}\"" shift 1 done - echo "${items[@]}" } - # Searches for the expected value in the follow-on arguments. If your list is sorted and has # more than ~40 items, consider using 'contains_item_sorted'. # diff --git a/tests/shlib_tests/lib_tests/arrays_tests/double_quote_items_test.sh b/tests/shlib_tests/lib_tests/arrays_tests/double_quote_items_test.sh index 887a7a25..f2473f83 100755 --- a/tests/shlib_tests/lib_tests/arrays_tests/double_quote_items_test.sh +++ b/tests/shlib_tests/lib_tests/arrays_tests/double_quote_items_test.sh @@ -16,28 +16,35 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" arrays_sh_location=cgrindel_bazel_starlib/shlib/lib/arrays.sh arrays_sh="$(rlocation "${arrays_sh_location}")" || \ (echo >&2 "Failed to locate ${arrays_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/arrays.sh source "${arrays_sh}" # MARK - Test args=(a b c) -actual=( $( double_quote_items "${args[@]}" ) ) +actual=() +while IFS=$'\n' read -r line; do actual+=("$line"); done < <( + double_quote_items "${args[@]}" +) assert_equal 3 ${#actual[@]} assert_equal "\"a\"" "${actual[0]}" assert_equal "\"b\"" "${actual[1]}" assert_equal "\"c\"" "${actual[2]}" -# GH076: Figure out how to handle returning items with spaces. -# # Ensure args with spaces works properly. -# args=("hello world" "chicken smidgen" "howdy, joe") -# actual=( $( double_quote_items "${args[@]}" ) ) -# assert_equal 3 ${#actual[@]} -# assert_equal "\"hello world\"" "${actual[0]}" -# assert_equal "\"chicken smidgen\"" "${actual[1]}" -# assert_equal "\"howdy, joe\"" "${actual[2]}" +# Ensure args with spaces works properly. +args=("hello world" "chicken smidgen" "howdy, joe") +actual=() +while IFS=$'\n' read -r line; do actual+=("$line"); done < <( + double_quote_items "${args[@]}" +) +assert_equal 3 ${#actual[@]} +assert_equal "\"hello world\"" "${actual[0]}" +assert_equal "\"chicken smidgen\"" "${actual[1]}" +assert_equal "\"howdy, joe\"" "${actual[2]}" From 44cfef4052f9fa64740224020f22f8524034db31 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:18:13 -0600 Subject: [PATCH 48/73] Address ShellCheck issues in join_by_test.sh. --- .../lib_tests/arrays_tests/join_by_test.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/shlib_tests/lib_tests/arrays_tests/join_by_test.sh b/tests/shlib_tests/lib_tests/arrays_tests/join_by_test.sh index 517fb7ad..bf1e98fc 100755 --- a/tests/shlib_tests/lib_tests/arrays_tests/join_by_test.sh +++ b/tests/shlib_tests/lib_tests/arrays_tests/join_by_test.sh @@ -11,11 +11,17 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e # --- end runfiles.bash initialization v3 --- -assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" -source "${assertions_lib}" +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh +source "${assertions_sh}" -arrays_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/arrays.sh)" -source "${arrays_lib}" +arrays_sh_location=cgrindel_bazel_starlib/shlib/lib/arrays.sh +arrays_sh="$(rlocation "${arrays_sh_location}")" || \ + (echo >&2 "Failed to locate ${arrays_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/arrays.sh +source "${arrays_sh}" args=(a c b) From a9aa98fff58717d7b1b5892366ffdecc9a630168 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:18:56 -0600 Subject: [PATCH 49/73] Address ShellCheck issues in print_by_line_test.sh. --- .../lib_tests/arrays_tests/print_by_line_test.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/shlib_tests/lib_tests/arrays_tests/print_by_line_test.sh b/tests/shlib_tests/lib_tests/arrays_tests/print_by_line_test.sh index 3d05674d..2de0c88d 100755 --- a/tests/shlib_tests/lib_tests/arrays_tests/print_by_line_test.sh +++ b/tests/shlib_tests/lib_tests/arrays_tests/print_by_line_test.sh @@ -11,11 +11,17 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e # --- end runfiles.bash initialization v3 --- -assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" -source "${assertions_lib}" +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh +source "${assertions_sh}" -arrays_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/arrays.sh)" -source "${arrays_lib}" +arrays_sh_location=cgrindel_bazel_starlib/shlib/lib/arrays.sh +arrays_sh="$(rlocation "${arrays_sh_location}")" || \ + (echo >&2 "Failed to locate ${arrays_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/arrays.sh +source "${arrays_sh}" # No args actual=$(print_by_line) From 6cfe61b7696e547c6dc5720766cd66554a841fb2 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:20:43 -0600 Subject: [PATCH 50/73] Address ShellCheck issues in sort_items_test.sh. --- .../lib_tests/arrays_tests/sort_items_test.sh | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/shlib_tests/lib_tests/arrays_tests/sort_items_test.sh b/tests/shlib_tests/lib_tests/arrays_tests/sort_items_test.sh index 1a25f1f4..d4520894 100755 --- a/tests/shlib_tests/lib_tests/arrays_tests/sort_items_test.sh +++ b/tests/shlib_tests/lib_tests/arrays_tests/sort_items_test.sh @@ -11,15 +11,25 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e # --- end runfiles.bash initialization v3 --- -assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" -source "${assertions_lib}" +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh +source "${assertions_sh}" + +arrays_sh_location=cgrindel_bazel_starlib/shlib/lib/arrays.sh +arrays_sh="$(rlocation "${arrays_sh_location}")" || \ + (echo >&2 "Failed to locate ${arrays_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/arrays.sh +source "${arrays_sh}" -arrays_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/arrays.sh)" -source "${arrays_lib}" array=(b e a c e) expected=(a b c e) -actual=( $(sort_items "${array[@]}") ) +actual=() +while IFS=$'\n' read -r line; do actual+=("$line"); done < <( + sort_items "${array[@]}" +) assert_equal "${#expected[@]}" "${#actual[@]}" for (( i = 0; i < ${#expected[@]}; i++ )); do From 302f19ca1cd296e17af37a159b284932ec0629cb Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:22:12 -0600 Subject: [PATCH 51/73] Address ShellCheck issues in assert_equal_test.sh. --- .../shlib_tests/lib_tests/assertions_tests/assert_equal_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib_tests/lib_tests/assertions_tests/assert_equal_test.sh b/tests/shlib_tests/lib_tests/assertions_tests/assert_equal_test.sh index 2c6ef6e7..88f16443 100755 --- a/tests/shlib_tests/lib_tests/assertions_tests/assert_equal_test.sh +++ b/tests/shlib_tests/lib_tests/assertions_tests/assert_equal_test.sh @@ -14,11 +14,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" assert_fail_sh_location=cgrindel_bazel_starlib/tests/shlib_tests/lib_tests/assertions_tests/assert_fail.sh assert_fail_sh="$(rlocation "${assert_fail_sh_location}")" || \ (echo >&2 "Failed to locate ${assert_fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/assert_fail.sh source "${assert_fail_sh}" From b8a9508dadf76f2b090c1b43285815c6736b55a6 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:26:03 -0600 Subject: [PATCH 52/73] Address issues in assert_fail.sh. --- .../lib_tests/assertions_tests/assert_fail.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/shlib_tests/lib_tests/assertions_tests/assert_fail.sh b/tests/shlib_tests/lib_tests/assertions_tests/assert_fail.sh index ef0eee1f..5b0e24c5 100644 --- a/tests/shlib_tests/lib_tests/assertions_tests/assert_fail.sh +++ b/tests/shlib_tests/lib_tests/assertions_tests/assert_fail.sh @@ -12,19 +12,21 @@ reset_fail_err_msgs() { } new_fail(){ - local err_msg="${1:-}" - [[ -n "${err_msg}" ]] || err_msg="Unspecified error occurred." - echo >&2 "${err_msg}" + if [[ $# -eq 0 ]]; then + echo >&2 "Unspecified error occurred." + else + echo >&2 "${@}" + fi exit 1 } assert_fail() { local pattern=${1} [[ ${#FAIL_ERR_MSGS[@]} == 0 ]] && new_fail "Expected a failure. None found. pattern: ${pattern}" - [[ ${#FAIL_ERR_MSGS[@]} > 1 ]] && new_fail "Expected a single failure. Found ${#FAIL_ERR_MSGS[@]}. pattern: ${pattern}" + [[ ${#FAIL_ERR_MSGS[@]} -gt 1 ]] && new_fail "Expected a single failure. Found ${#FAIL_ERR_MSGS[@]}. pattern: ${pattern}" [[ "${FAIL_ERR_MSGS[0]}" =~ ${pattern} ]] || new_fail "Unexpected failure. Found '${FAIL_ERR_MSGS[0]}'. pattern: ${pattern}" } assert_no_fail(){ - [[ ${#FAIL_ERR_MSGS[@]} == 0 ]] || new_fail "Expected no failures. Found ${#FAIL_ERR_MSGS[@]}. '${FAIL_ERR_MSGS[@]}'" + [[ ${#FAIL_ERR_MSGS[@]} == 0 ]] || new_fail "Expected no failures. Found ${#FAIL_ERR_MSGS[@]}." "${FAIL_ERR_MSGS[@]}" } From a28b6d26b3ef540c89a6c800e88f8151e51756d3 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:26:57 -0600 Subject: [PATCH 53/73] Address ShellCheck issues in assert_match_test.sh. --- .../shlib_tests/lib_tests/assertions_tests/assert_match_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib_tests/lib_tests/assertions_tests/assert_match_test.sh b/tests/shlib_tests/lib_tests/assertions_tests/assert_match_test.sh index 11413e31..b4f9304b 100755 --- a/tests/shlib_tests/lib_tests/assertions_tests/assert_match_test.sh +++ b/tests/shlib_tests/lib_tests/assertions_tests/assert_match_test.sh @@ -14,11 +14,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" assert_fail_sh_location=cgrindel_bazel_starlib/tests/shlib_tests/lib_tests/assertions_tests/assert_fail.sh assert_fail_sh="$(rlocation "${assert_fail_sh_location}")" || \ (echo >&2 "Failed to locate ${assert_fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/assert_fail.sh source "${assert_fail_sh}" # MARK - Test assert_match From d28bcaf4089b1cd1a1da5ce4ea8c41f5191f43a9 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:27:38 -0600 Subject: [PATCH 54/73] Address ShellCheck issues in assert_no_match_test.sh. --- .../lib_tests/assertions_tests/assert_no_match_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib_tests/lib_tests/assertions_tests/assert_no_match_test.sh b/tests/shlib_tests/lib_tests/assertions_tests/assert_no_match_test.sh index b2267b11..cf820c99 100755 --- a/tests/shlib_tests/lib_tests/assertions_tests/assert_no_match_test.sh +++ b/tests/shlib_tests/lib_tests/assertions_tests/assert_no_match_test.sh @@ -14,11 +14,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" assert_fail_sh_location=cgrindel_bazel_starlib/tests/shlib_tests/lib_tests/assertions_tests/assert_fail.sh assert_fail_sh="$(rlocation "${assert_fail_sh_location}")" || \ (echo >&2 "Failed to locate ${assert_fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/assert_fail.sh source "${assert_fail_sh}" # MARK - Test assert_no_match From e4af9ee06763a8a0011379f3ccee81c7a466e8e6 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:29:31 -0600 Subject: [PATCH 55/73] Address ShellCheck issues in upsearch_test.sh. --- .../lib_tests/files_tests/upsearch_test.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/shlib_tests/lib_tests/files_tests/upsearch_test.sh b/tests/shlib_tests/lib_tests/files_tests/upsearch_test.sh index 9c740ed3..ca614a85 100755 --- a/tests/shlib_tests/lib_tests/files_tests/upsearch_test.sh +++ b/tests/shlib_tests/lib_tests/files_tests/upsearch_test.sh @@ -11,11 +11,17 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e # --- end runfiles.bash initialization v3 --- -assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" -source "${assertions_lib}" - -files_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/files.sh)" -source "${files_lib}" +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh +source "${assertions_sh}" + +files_sh_location=cgrindel_bazel_starlib/shlib/lib/files.sh +files_sh="$(rlocation "${files_sh_location}")" || \ + (echo >&2 "Failed to locate ${files_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/files.sh +source "${files_sh}" # MARK - Setup From 218371e6aea4a9dc38e8b9a0e1b19b3f900d90cf Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:36:33 -0600 Subject: [PATCH 56/73] Address ShellCheck issues in git_integration_test.sh. --- shlib/lib/git.sh | 5 +++-- .../lib_tests/git_tests/git_integration_test.sh | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/shlib/lib/git.sh b/shlib/lib/git.sh index 9a4f1e46..dbe7986e 100644 --- a/shlib/lib/git.sh +++ b/shlib/lib/git.sh @@ -53,8 +53,9 @@ get_git_release_tags() { for tag in "${tags[@]}" ; do is_valid_release_tag "${tag}" && release_tags+=( "${tag}" ) done - [[ ${#release_tags[@]} == 0 ]] && return - echo "${release_tags[@]}" + for release_tag in "${release_tags[@]}" ; do + echo "${release_tag}" + done } git_tag_exists() { diff --git a/tests/shlib_tests/lib_tests/git_tests/git_integration_test.sh b/tests/shlib_tests/lib_tests/git_tests/git_integration_test.sh index 20309732..d7881c3b 100755 --- a/tests/shlib_tests/lib_tests/git_tests/git_integration_test.sh +++ b/tests/shlib_tests/lib_tests/git_tests/git_integration_test.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/env.sh source "${env_sh}" setup_git_repo_sh_location=cgrindel_bazel_starlib/tests/setup_git_repo.sh @@ -30,17 +32,20 @@ setup_git_repo_sh="$(rlocation "${setup_git_repo_sh_location}")" || \ git_sh_location=cgrindel_bazel_starlib/shlib/lib/git.sh git_sh="$(rlocation "${git_sh_location}")" || \ (echo >&2 "Failed to locate ${git_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/git.sh source "${git_sh}" arrays_sh_location=cgrindel_bazel_starlib/shlib/lib/arrays.sh arrays_sh="$(rlocation "${arrays_sh_location}")" || \ (echo >&2 "Failed to locate ${arrays_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/arrays.sh source "${arrays_sh}" is_installed git || fail "Could not find git." # MARK - Setup +# shellcheck source=SCRIPTDIR/../../../setup_git_repo.sh source "${setup_git_repo_sh}" cd "${repo_dir}" @@ -59,6 +64,7 @@ remote_url="$(get_git_remote_url)" [[ "${remote_url}" =~ "bazel-starlib" ]] || fail "Unexpected remote URL." # Make sure that fetch does not fail +# shellcheck disable=SC2119 # optional arguments fetch_latest_from_git_remote # Create a non-release tag @@ -69,8 +75,12 @@ git_tag_exists "howdy" || fail "Expected tag 'howdy' to exist." create_git_release_tag "3.2.1" git_tag_exists "3.2.1" || fail "Expected tag '3.2.1' to exist." -release_tags=( $(get_git_release_tags) ) -[[ ${#release_tags[@]} > 0 ]] || fail "Did not find any release tags." +# release_tags=( $(get_git_release_tags) ) +release_tags=() +while IFS=$'\n' read -r line; do release_tags+=("$line"); done < <( + get_git_release_tags +) +[[ ${#release_tags[@]} -gt 0 ]] || fail "Did not find any release tags." contains_item "v0.1.1" "${release_tags[@]}" || fail "Expected tag 'v0.1.1' to be found as a release tag." contains_item "3.2.1" "${release_tags[@]}" || fail "Expected tag '3.2.1' to be found as a release tag." From fbe882b9d12a8d13bbbe2fb110781f4f2f9533f2 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:37:35 -0600 Subject: [PATCH 57/73] Address ShellCheck issues in get_gh_api_base_url_test.sh. --- .../lib_tests/github_tests/get_gh_api_base_url_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib_tests/lib_tests/github_tests/get_gh_api_base_url_test.sh b/tests/shlib_tests/lib_tests/github_tests/get_gh_api_base_url_test.sh index 7ec5ddaa..3bd4a852 100755 --- a/tests/shlib_tests/lib_tests/github_tests/get_gh_api_base_url_test.sh +++ b/tests/shlib_tests/lib_tests/github_tests/get_gh_api_base_url_test.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/github.sh source "${github_sh}" From 34982a5d2dc254c1cc19318c0db8aea48e1953dc Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:38:59 -0600 Subject: [PATCH 58/73] Address ShellCheck issues in get_gh_auth_status_test.sh. --- .../lib_tests/github_tests/get_gh_auth_status_test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/shlib_tests/lib_tests/github_tests/get_gh_auth_status_test.sh b/tests/shlib_tests/lib_tests/github_tests/get_gh_auth_status_test.sh index 7f898b9f..1b6320cf 100755 --- a/tests/shlib_tests/lib_tests/github_tests/get_gh_auth_status_test.sh +++ b/tests/shlib_tests/lib_tests/github_tests/get_gh_auth_status_test.sh @@ -16,16 +16,19 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/env.sh source "${env_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/github.sh source "${github_sh}" is_installed gh || fail "Could not find Github CLI (gh)." From 5aae8068dbfce3368533185bcfaa285174e2adc4 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:41:50 -0600 Subject: [PATCH 59/73] Address ShellCheck issues in get_gh_changelog_test.sh. --- .../lib_tests/github_tests/get_gh_auth_token_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib_tests/lib_tests/github_tests/get_gh_auth_token_test.sh b/tests/shlib_tests/lib_tests/github_tests/get_gh_auth_token_test.sh index a8b7344a..cd7ad3d9 100755 --- a/tests/shlib_tests/lib_tests/github_tests/get_gh_auth_token_test.sh +++ b/tests/shlib_tests/lib_tests/github_tests/get_gh_auth_token_test.sh @@ -14,11 +14,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/github.sh source "${github_sh}" From 36e6532bcc7d5080e9423f9a362b4352fee706a4 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:42:03 -0600 Subject: [PATCH 60/73] Address ShellCheck issues in get_gh_changelog_test.sh. --- .../lib_tests/github_tests/get_gh_changelog_test.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/shlib_tests/lib_tests/github_tests/get_gh_changelog_test.sh b/tests/shlib_tests/lib_tests/github_tests/get_gh_changelog_test.sh index 3d5b0732..2b0fc492 100755 --- a/tests/shlib_tests/lib_tests/github_tests/get_gh_changelog_test.sh +++ b/tests/shlib_tests/lib_tests/github_tests/get_gh_changelog_test.sh @@ -16,16 +16,19 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" env_sh_location=cgrindel_bazel_starlib/shlib/lib/env.sh env_sh="$(rlocation "${env_sh_location}")" || \ (echo >&2 "Failed to locate ${env_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/env.sh source "${env_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/github.sh source "${github_sh}" setup_git_repo_sh_location=cgrindel_bazel_starlib/tests/setup_git_repo.sh @@ -36,6 +39,7 @@ is_installed gh || fail "Could not find Github CLI (gh)." # MARK - Setup +# shellcheck source=SCRIPTDIR/../../../setup_git_repo.sh source "${setup_git_repo_sh}" cd "${repo_dir}" @@ -44,6 +48,6 @@ cd "${repo_dir}" tag_name="v0.1.1" prev_tag_name="v0.1.0" result="$( get_gh_changelog --tag_name "${tag_name}" --previous_tag_name "${prev_tag_name}" )" -[[ "${result}" =~ "**Full Changelog**: https://github.com/cgrindel/bazel-starlib/compare/v0.1.0...v0.1.1" ]] || \ +[[ "${result}" =~ \*\*Full\ Changelog\*\*:\ https://github\.com/cgrindel/bazel-starlib/compare/v0\.1\.0\.\.\.v0\.1\.1 ]] || \ fail "Expected to find changelog URL for v0.1.0...v0.1.1. result: ${result}" From f0ef1c0232f61d5f63f7e8fed5ae78486c1c3551 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:43:14 -0600 Subject: [PATCH 61/73] Address ShellCheck issues in get_gh_repo_name_test.sh. --- .../shlib_tests/lib_tests/github_tests/get_gh_repo_name_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib_tests/lib_tests/github_tests/get_gh_repo_name_test.sh b/tests/shlib_tests/lib_tests/github_tests/get_gh_repo_name_test.sh index 74330028..09ab5d49 100755 --- a/tests/shlib_tests/lib_tests/github_tests/get_gh_repo_name_test.sh +++ b/tests/shlib_tests/lib_tests/github_tests/get_gh_repo_name_test.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/github.sh source "${github_sh}" From 0734706169d653708ca53c2bb05fc18f9ad488a9 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:44:00 -0600 Subject: [PATCH 62/73] Address ShellCheck issues in get_gh_repo_owner_test.sh. --- .../lib_tests/github_tests/get_gh_repo_owner_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib_tests/lib_tests/github_tests/get_gh_repo_owner_test.sh b/tests/shlib_tests/lib_tests/github_tests/get_gh_repo_owner_test.sh index 86aa13e7..2e671ccb 100755 --- a/tests/shlib_tests/lib_tests/github_tests/get_gh_repo_owner_test.sh +++ b/tests/shlib_tests/lib_tests/github_tests/get_gh_repo_owner_test.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/github.sh source "${github_sh}" From 22af68e10e73c0c8b50123847979ed0b52ddafba Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:44:43 -0600 Subject: [PATCH 63/73] Address ShellCheck issues in get_gh_username_test.sh. --- .../shlib_tests/lib_tests/github_tests/get_gh_username_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib_tests/lib_tests/github_tests/get_gh_username_test.sh b/tests/shlib_tests/lib_tests/github_tests/get_gh_username_test.sh index 42aba2c9..d8a3dbbc 100755 --- a/tests/shlib_tests/lib_tests/github_tests/get_gh_username_test.sh +++ b/tests/shlib_tests/lib_tests/github_tests/get_gh_username_test.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/github.sh source "${github_sh}" From a2bb7bbdf0e8eafe9bc6db5a398f61ad7785672c Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:45:23 -0600 Subject: [PATCH 64/73] Address ShellCheck issues in is_github_repo_url_test.sh. --- .../lib_tests/github_tests/is_github_repo_url_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib_tests/lib_tests/github_tests/is_github_repo_url_test.sh b/tests/shlib_tests/lib_tests/github_tests/is_github_repo_url_test.sh index d96ce7d1..fc05a29b 100755 --- a/tests/shlib_tests/lib_tests/github_tests/is_github_repo_url_test.sh +++ b/tests/shlib_tests/lib_tests/github_tests/is_github_repo_url_test.sh @@ -16,11 +16,13 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" github_sh_location=cgrindel_bazel_starlib/shlib/lib/github.sh github_sh="$(rlocation "${github_sh_location}")" || \ (echo >&2 "Failed to locate ${github_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/github.sh source "${github_sh}" From 543c833698c1db35d5b97e90788d3ccf27c560a0 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:47:23 -0600 Subject: [PATCH 65/73] Address ShellCheck issues in exit_with_msg_test.sh. --- .../messages_tests/exit_with_msg_test.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/shlib_tests/lib_tests/messages_tests/exit_with_msg_test.sh b/tests/shlib_tests/lib_tests/messages_tests/exit_with_msg_test.sh index 4c78e1e2..e1a3e2cd 100755 --- a/tests/shlib_tests/lib_tests/messages_tests/exit_with_msg_test.sh +++ b/tests/shlib_tests/lib_tests/messages_tests/exit_with_msg_test.sh @@ -11,11 +11,17 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e # --- end runfiles.bash initialization v3 --- -assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" -source "${assertions_lib}" - -messages_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/messages.sh)" -source "${messages_lib}" +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh +source "${assertions_sh}" + +messages_sh_location=cgrindel_bazel_starlib/shlib/lib/messages.sh +messages_sh="$(rlocation "${messages_sh_location}")" || \ + (echo >&2 "Failed to locate ${messages_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/messages.sh +source "${messages_sh}" # Disable errexit so that we can capture the exit codes set +e From 4798448429946b35d1f572fa79945849e95fa7dc Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:49:06 -0600 Subject: [PATCH 66/73] Address ShellCheck issues in normalize_path_test.sh. --- .../lib_tests/paths_tests/normalize_path_test.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/shlib_tests/lib_tests/paths_tests/normalize_path_test.sh b/tests/shlib_tests/lib_tests/paths_tests/normalize_path_test.sh index 703c5654..7528d35f 100755 --- a/tests/shlib_tests/lib_tests/paths_tests/normalize_path_test.sh +++ b/tests/shlib_tests/lib_tests/paths_tests/normalize_path_test.sh @@ -11,11 +11,17 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e # --- end runfiles.bash initialization v3 --- -assertions_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/assertions.sh)" -source "${assertions_lib}" +assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh +assertions_sh="$(rlocation "${assertions_sh_location}")" || \ + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh +source "${assertions_sh}" -paths_lib="$(rlocation cgrindel_bazel_starlib/shlib/lib/paths.sh)" -source "${paths_lib}" +paths_sh_location=cgrindel_bazel_starlib/shlib/lib/paths.sh +paths_sh="$(rlocation "${paths_sh_location}")" || \ + (echo >&2 "Failed to locate ${paths_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/paths.sh +source "${paths_sh}" current_dir="${PWD}" From c7d62eaebd99e7f6cd9686f927ab6fa3055caea8 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:50:24 -0600 Subject: [PATCH 67/73] Address ShellCheck issues in execute_binary_no_args_test.sh. --- .../execute_binary_tests/execute_binary_no_args_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/shlib_tests/rules_tests/execute_binary_tests/execute_binary_no_args_test.sh b/tests/shlib_tests/rules_tests/execute_binary_tests/execute_binary_no_args_test.sh index a4a64da6..47e02655 100755 --- a/tests/shlib_tests/rules_tests/execute_binary_tests/execute_binary_no_args_test.sh +++ b/tests/shlib_tests/rules_tests/execute_binary_tests/execute_binary_no_args_test.sh @@ -14,6 +14,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" my_bin_no_args_sh_location=cgrindel_bazel_starlib/tests/shlib_tests/rules_tests/execute_binary_tests/my_bin_no_args.sh From c4dd87b7d0d6b65b3ddf7b800e37fffffd5ac5b5 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:53:40 -0600 Subject: [PATCH 68/73] Address ShellCheck issues in execute_binary_with_args_test.sh. --- .../execute_binary_tests/execute_binary_with_args_test.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/shlib_tests/rules_tests/execute_binary_tests/execute_binary_with_args_test.sh b/tests/shlib_tests/rules_tests/execute_binary_tests/execute_binary_with_args_test.sh index 5e630e63..59c78735 100755 --- a/tests/shlib_tests/rules_tests/execute_binary_tests/execute_binary_with_args_test.sh +++ b/tests/shlib_tests/rules_tests/execute_binary_tests/execute_binary_with_args_test.sh @@ -14,6 +14,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" my_bin_with_args_sh_location=cgrindel_bazel_starlib/tests/shlib_tests/rules_tests/execute_binary_tests/my_bin_with_args.sh @@ -26,7 +27,7 @@ assert_arg() { local output="${1}" local index="${2}" local value="${3}" - [[ "${output}" =~ " ${index}: ${value}" ]] || fail "Expected ${index}: ${value} + [[ "${output}" =~ \ \ ${index}:\ ${value} ]] || fail "Expected ${index}: ${value} ${output} " } @@ -50,8 +51,8 @@ ${output} assert_embedded_args "${output}" -[[ "${output}" =~ "Data: This is a data file." ]] || fail "Did not see data file output." -[[ "${output}" =~ "Input: This is an input file." ]] || fail "Did not see input file output." +[[ "${output}" =~ Data:\ This\ is\ a\ data\ file\. ]] || fail "Did not see data file output." +[[ "${output}" =~ Input:\ This\ is\ an\ input\ file\. ]] || fail "Did not see input file output." # MARK - Test that additional arguments are passed along properly From 29c48c74c03146b4f598cb946533063bcfc4aa84 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:54:14 -0600 Subject: [PATCH 69/73] Address ShellCheck issues in find_workspace_eb_test.sh. --- .../rules_tests/execute_binary_tests/find_workspace_eb_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/shlib_tests/rules_tests/execute_binary_tests/find_workspace_eb_test.sh b/tests/shlib_tests/rules_tests/execute_binary_tests/find_workspace_eb_test.sh index e42e3d99..b07454e4 100755 --- a/tests/shlib_tests/rules_tests/execute_binary_tests/find_workspace_eb_test.sh +++ b/tests/shlib_tests/rules_tests/execute_binary_tests/find_workspace_eb_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" # tests/shlib_tests/rules_tests/execute_binary_tests From 137e591fc9e66a623b1e39fb775537a91c8674ad Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:58:19 -0600 Subject: [PATCH 70/73] Address ShellCheck issues in my_bin.sh. --- tests/shlib_tests/rules_tests/execute_binary_tests/my_bin.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/shlib_tests/rules_tests/execute_binary_tests/my_bin.sh b/tests/shlib_tests/rules_tests/execute_binary_tests/my_bin.sh index bdaef4c0..213ed51f 100755 --- a/tests/shlib_tests/rules_tests/execute_binary_tests/my_bin.sh +++ b/tests/shlib_tests/rules_tests/execute_binary_tests/my_bin.sh @@ -13,8 +13,8 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ # MARK - Args Count -args_count=($# - 1) -echo "Args Count: ${args_count}" + +echo "Args Count: ${#}" for (( i = 1; i <= ${#}; i++ )); do echo " ${i}: ${!i}" done From 7334bad67e8230850746465f7fc2d5c9d4250584 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:58:54 -0600 Subject: [PATCH 71/73] Address ShellCheck issues in process_file.sh. --- .../rules_tests/execute_binary_tests/process_file.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/shlib_tests/rules_tests/execute_binary_tests/process_file.sh b/tests/shlib_tests/rules_tests/execute_binary_tests/process_file.sh index d2c7d27b..26de4fb3 100755 --- a/tests/shlib_tests/rules_tests/execute_binary_tests/process_file.sh +++ b/tests/shlib_tests/rules_tests/execute_binary_tests/process_file.sh @@ -35,7 +35,7 @@ done data="$(< "${data_file_txt}")" echo "Data: ${data}" -if [[ ! -z "${arg_file:-}" ]]; then +if [[ -n "${arg_file:-}" ]]; then arg_file_data="$(< "${arg_file}")" echo "Arg File: ${arg_file_data}" fi From 2137d607ce8bbed6c7f3ede4bcfc40b48c684820 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 11:59:27 -0600 Subject: [PATCH 72/73] Address ShellCheck issues in process_file_consumer.sh. --- .../rules_tests/execute_binary_tests/process_file_consumer.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/shlib_tests/rules_tests/execute_binary_tests/process_file_consumer.sh b/tests/shlib_tests/rules_tests/execute_binary_tests/process_file_consumer.sh index 5bee35eb..3fce3532 100755 --- a/tests/shlib_tests/rules_tests/execute_binary_tests/process_file_consumer.sh +++ b/tests/shlib_tests/rules_tests/execute_binary_tests/process_file_consumer.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ fail_sh_location=cgrindel_bazel_starlib/shlib/lib/fail.sh fail_sh="$(rlocation "${fail_sh_location}")" || \ (echo >&2 "Failed to locate ${fail_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/fail.sh source "${fail_sh}" From 8210e24bd1636bda0432ba686143ad8db09484f3 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 18 Jul 2023 12:00:12 -0600 Subject: [PATCH 73/73] Address ShellCheck issues in process_file_consumer_eb_test.sh. --- .../execute_binary_tests/process_file_consumer_eb_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/shlib_tests/rules_tests/execute_binary_tests/process_file_consumer_eb_test.sh b/tests/shlib_tests/rules_tests/execute_binary_tests/process_file_consumer_eb_test.sh index da09849c..b1706c49 100755 --- a/tests/shlib_tests/rules_tests/execute_binary_tests/process_file_consumer_eb_test.sh +++ b/tests/shlib_tests/rules_tests/execute_binary_tests/process_file_consumer_eb_test.sh @@ -16,6 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh assertions_sh="$(rlocation "${assertions_sh_location}")" || \ (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +# shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" process_file_consumer_eb_sh_location=cgrindel_bazel_starlib/tests/shlib_tests/rules_tests/execute_binary_tests/process_file_consumer_eb.sh