From aeeabf5d1cd8790ed8b54f6ce455fe5751c7f4f1 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 28 Apr 2023 08:40:11 -0400 Subject: [PATCH] Replace very cute (ab)use of array to get first element with explicit awk That is to overcome warnings from shellcheck In .clusterfuzzlite/build.sh line 8: hash=($(sha256sum "$file")) ^------------------^ SC2207 (warning): Prefer mapfile or read -a to split command output (or quote to avoid splitting). In .clusterfuzzlite/build.sh line 9: cp "$file" "/tmp/oxigraph_$1/$hash" ^---^ SC2128 (warning): Expanding an array without an index only gives the first element. although original code is making a cute use of an array, if we are to follow shellcheck and use mapfile or read -a - and then use explicit index -- makes it just too cumbersome. IMHO explicit awk would be easier to read etc. --- .clusterfuzzlite/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clusterfuzzlite/build.sh b/.clusterfuzzlite/build.sh index b48e2c4e..31f59bd2 100755 --- a/.clusterfuzzlite/build.sh +++ b/.clusterfuzzlite/build.sh @@ -5,7 +5,7 @@ function build_seed_corpus() { mkdir "/tmp/oxigraph_$1" for file in **/*."$2" do - hash=($(sha256sum "$file")) + hash=$(sha256sum "$file" | awk '{print $1;}') cp "$file" "/tmp/oxigraph_$1/$hash" done zip "$1_seed_corpus.zip" /tmp/"oxigraph_$1"/*