From d667a1d116ae8f4301e446f7107bea78ac39fd99 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 30 May 2023 11:48:28 -0400 Subject: [PATCH] Address shellcheck checks --- .github/workflows/base-tests.yaml | 2 +- scripts/freeze_versions | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/base-tests.yaml b/.github/workflows/base-tests.yaml index 79eed36e..855895aa 100644 --- a/.github/workflows/base-tests.yaml +++ b/.github/workflows/base-tests.yaml @@ -49,7 +49,7 @@ jobs: run: | find . -name .git -prune -o -type f \ '!' '(' -name '*.txt' -o -name '*.md' ')' \ - -exec grep -q -m1 '^#!/bin/.*sh' {} ';' \ + -exec grep -q -m1 '^#!/bin/\(ba\|da\|k\)\?sh' {} ';' \ -print0 \ | xargs -0 shellcheck diff --git a/scripts/freeze_versions b/scripts/freeze_versions index 5c215856..7fbdea84 100755 --- a/scripts/freeze_versions +++ b/scripts/freeze_versions @@ -127,12 +127,12 @@ for arg in "$@"; do # we were specified precisely with extension etc imgpath="$imgprefix" else - imgpaths=( $(/bin/ls -1 "$imgprefix".*) ) + mapfile -t imgpaths < <( /bin/ls -1 "$imgprefix".* ) case ${#imgpaths[@]} in 0) error "There is no ${imgprefix}.* files. Available images for the app are:" /bin/ls -1 "$topd/images/${img%%-*}/${img}--"* | sed -e 's,^, ,g' 1>&2 exit 1;; - 1) imgpath=$(realpath -ms --relative-to="${save_ds:-.}" ${imgpaths[0]});; # already would include topd + 1) imgpath=$(realpath -ms --relative-to="${save_ds:-.}" "${imgpaths[0]}");; # already would include topd *) error "There are multiple images available. Include extension into your version specification. Available images are:" echo "${imgpaths[@]}" | sed -e 's, ,\n ,g' -e 's,^, ,g' exit 1;; @@ -149,13 +149,13 @@ for arg in "$@"; do # if it was a copy into some other super-dataset, we should copy some other fields if [ -n "$topd_rel" ]; then # if copying to some other dataset, procedure is different, since we need to copy all - git config -f $topd/.datalad/config --get-regexp "containers.${img}\." \ - | while read var value; do + git config -f "$topd"/.datalad/config --get-regexp "containers.${img}\." \ + | while read -r var value; do case "${var##*.}" in image) continue;; # already done above, skip cmdexec) if echo "$value" | grep -q '^{img_dspath}/'; then - value=$(echo "$value" | sed -e "s,{img_dspath}/,{img_dspath}/$topd_rel,g") + value="${value//{img_dspath}\//{img_dspath}\/$topd_rel}" else value="$topd_rel$value" fi;;