From 3235f526d669a3ad53b081846a75beab774ef081 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 19 Sep 2024 12:06:53 +0000 Subject: [PATCH] Apply shellcheck's recommendations --- .github/workflows/publish.yml | 4 +-- transform_binary.sh | 46 +++++++++++++++++------------------ 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2b4ae1b..7535488 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,7 +20,7 @@ jobs: HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{ github.token }} HOMEBREW_GITHUB_PACKAGES_USER: ${{ github.actor }} PULL_REQUEST: ${{ github.event.pull_request.number }} - run: brew pr-pull --debug --tap=$GITHUB_REPOSITORY $PULL_REQUEST + run: brew pr-pull --debug --tap="$GITHUB_REPOSITORY" "$PULL_REQUEST" - name: Push commits uses: Homebrew/actions/git-try-push@master @@ -32,4 +32,4 @@ jobs: if: github.event.pull_request.head.repo.fork == false env: BRANCH: ${{ github.event.pull_request.head.ref }} - run: git push --delete origin $BRANCH + run: git push --delete origin "$BRANCH" diff --git a/transform_binary.sh b/transform_binary.sh index d63d53f..e7e23d3 100755 --- a/transform_binary.sh +++ b/transform_binary.sh @@ -2,7 +2,7 @@ VERSION=$1 -if [ -z "${VERSION}" ]; then +if [[ -z "${VERSION}" ]]; then echo >&2 "Fatal error: VERSION not set" echo >&2 "Fatal error: Need to provide version, example: 5.62.0" exit 2 @@ -10,45 +10,43 @@ fi CBMC_STRING="CbmcAT" VERSION_PROCESSED="${VERSION//./}" -FORMULA_VERSION="$CBMC_STRING$VERSION_PROCESSED" +FORMULA_VERSION="${CBMC_STRING}${VERSION_PROCESSED}" echo "bottle do" echo " root_url \"https://github.com/diffblue/homebrew-cbmc/releases/download/bag-of-goodies\"" for TAG in "arm64_sonoma" "arm64_ventura" "arm64_monterey" "sonoma" "ventura" "monterey" "x86_64_linux" do #echo "Processing bottle for $VERSION -- $TAG" - OUTPUT=$(brew fetch cbmc --bottle-tag=$TAG) - OUTPUT=$(echo "$OUTPUT" | tail -n -2) + OUTPUT=$(brew fetch cbmc --bottle-tag="${TAG}") + OUTPUT=$(echo "${OUTPUT}" | tail -n -2) pat1='Downloaded to: (.*\.{1})(tgz|tar\.gz)' pat2='Already downloaded: (.*\.{1})(tgz|tar\.gz)' - if [[ $OUTPUT =~ $pat1 ]]; then + if [[ ${OUTPUT} =~ ${pat1} ]]; then BOTTLE_NAME=${BASH_REMATCH[1]} BOTTLE_NAME+="tar.gz" - tar -xzf $BOTTLE_NAME - mv cbmc cbmc@$1 - sed -iu "s/class Cbmc/class $FORMULA_VERSION/g" cbmc@$1/$1/.brew/cbmc.rb - tar czf cbmc@$1-$1.$TAG.bottle.tar.gz cbmc@$1 - rm -rf cbmc@$1 - #SHA=$(shasum -a 256 cbmc@$1-$1.$TAG.bottle.tar.gz) - #echo "$SHA" - LINE=" sha256 cellar: :any_skip_relocation, $TAG: \"$(shasum -a 256 cbmc@$1-$1.$TAG.bottle.tar.gz | awk '{print $1}')\"" - echo "$LINE" - elif [[ $OUTPUT =~ $pat2 ]]; then + tar -xzf "${BOTTLE_NAME}" + mv cbmc cbmc@"${VERSION}" + sed -iu "s/class Cbmc/class ${FORMULA_VERSION}/g" "cbmc@${VERSION}/${VERSION}/.brew/cbmc.rb" + tar czf "cbmc@${VERSION}-${VERSION}.${TAG}.bottle.tar.gz" cbmc@"${VERSION}" + rm -rf cbmc@"${VERSION}" + SHA=$(shasum -a 256 "cbmc@${VERSION}-${VERSION}.$TAG.bottle.tar.gz" | awk '{print $1}') + LINE=" sha256 cellar: :any_skip_relocation, $TAG: \"${SHA}\"" + echo "${LINE}" + elif [[ ${OUTPUT} =~ ${pat2} ]]; then BOTTLE_NAME=${BASH_REMATCH[1]} BOTTLE_NAME+="tar.gz" - tar -xzf $BOTTLE_NAME - mv cbmc cbmc@$1 - sed -iu "s/class Cbmc/class $FORMULA_VERSION/g" cbmc@$1/$1/.brew/cbmc.rb - tar czf cbmc@$1-$1.$TAG.bottle.tar.gz cbmc@$1 - rm -rf cbmc@$1 - #SHA=$(shasum -a 256 cbmc@$1-$1.$TAG.bottle.tar.gz) - #echo "$SHA" - LINE=" sha256 cellar: :any_skip_relocation, $TAG: \"$(shasum -a 256 cbmc@$1-$1.$TAG.bottle.tar.gz | awk '{print $1}')\"" - echo "$LINE" + tar -xzf "${BOTTLE_NAME}" + mv cbmc cbmc@"${VERSION}" + sed -iu "s/class Cbmc/class $FORMULA_VERSION/g" "cbmc@${VERSION}/${VERSION}/.brew/cbmc.rb" + tar czf "cbmc@${VERSION}-${VERSION}.${TAG}.bottle.tar.gz" cbmc@"${VERSION}" + rm -rf cbmc@"${VERSION}" + SHA=$(shasum -a 256 "cbmc@${VERSION}-${VERSION}.$TAG.bottle.tar.gz" | awk '{print $1}') + LINE=" sha256 cellar: :any_skip_relocation, $TAG: \"${SHA}\"" + echo "${LINE}" fi done echo end