From d0299deb3395006285589299cef71b2fb9b84118 Mon Sep 17 00:00:00 2001 From: chrysn Date: Thu, 3 Oct 2024 11:45:56 +0200 Subject: [PATCH] static_tests/rust: Address shellcheck lints The pure POSIX way to do `for x in $(find ...)` right involves a tempfile, thus limiting to bash. --- dist/tools/cargo-checks/check.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/dist/tools/cargo-checks/check.sh b/dist/tools/cargo-checks/check.sh index 41303832f8..3861b450c5 100755 --- a/dist/tools/cargo-checks/check.sh +++ b/dist/tools/cargo-checks/check.sh @@ -1,21 +1,17 @@ -#!/bin/sh +#!/bin/bash set -eu FAILURES="" -# This is a Make based environment, therefore we don't have funny names to take -# care of, and anyone who can cause commands to be run by injecting files can -# just as well modify the scripts being run. (Otherwise we'd need to go through -# a less readable print0 / read). -for CARGOTOML in `find -name Cargo.toml` +while IFS= read -r -d '' CARGOTOML do if cargo fmt --quiet --check --manifest-path "${CARGOTOML}"; then continue else FAILURES="${FAILURES} ${CARGOTOML%Cargo.toml}" fi -done +done < <(find . -name Cargo.toml -print0) if [ x"" != x"${FAILURES}" ]; then echo "Some Rust files are following rustfmt, in particular in:" @@ -23,7 +19,7 @@ if [ x"" != x"${FAILURES}" ]; then echo "You can format the code locally using:" echo echo "find -name Cargo.toml -exec cargo fmt --manifest-path '{}' ';'" - if [ ! -z "${GITHUB_RUN_ID:-}" ]; then + if [ -n "${GITHUB_RUN_ID:-}" ]; then echo echo "The author of this test regrets not knowing how to provide an easy way to just click a button here that provides the right fixup commits." fi