Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix shellcheck nits
Browse files Browse the repository at this point in the history
  • Loading branch information
chevdor committed Sep 8, 2021
1 parent bb30717 commit f8ea3d2
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions scripts/github/extrinsic-ordering-filter.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env bash
# This script is used in a Github Workflow. It helps filtering out what is interesting
# when comparing metadata and spot what would require a tx version bump.

#!/usr/bin/env bash
# shellcheck disable=SC2002

FILE=$1

function find_index_changes() {
echo "\n## Index changes\n"
RES=$(cat $FILE | egrep -n -i 'idx:\s*([0-9]+)\s*(->)\s*([0-9]+)' | tr -s " ")
printf "\n## Index changes\n"
RES=$(cat "$FILE" | grep -E -n -i 'idx:\s*([0-9]+)\s*(->)\s*([0-9]+)' | tr -s " ")
if [ "$RES" ]; then
echo "$RES" | awk '{ printf "%s\\n", $0 }'
else
Expand All @@ -16,8 +17,8 @@ function find_index_changes() {
}

function find_deletions() {
echo "\n## Deletions\n"
RES=$(cat $FILE | grep -n '\[\-\]' | tr -s " ")
printf "\n## Deletions\n"
RES=$(cat "$FILE" | grep -n '\[\-\]' | tr -s " ")
if [ "$RES" ]; then
echo "$RES" | awk '{ printf "%s\\n", $0 }'
else
Expand All @@ -26,13 +27,13 @@ function find_deletions() {
}

function find_decreases() {
echo "\n## Decreases\n"
OUT=$(cat $FILE | egrep -i -o '([0-9]+)\s*(->)\s*([0-9]+)' | awk '$1 > $3 { printf "%s;", $0 }')
IFS=$';' LIST=($OUT)
printf "\n## Decreases\n"
OUT=$(cat "$FILE" | grep -E -i -o '([0-9]+)\s*(->)\s*([0-9]+)' | awk '$1 > $3 { printf "%s;", $0 }')
IFS=$';' LIST=("$OUT")
unset RES
for line in "${LIST[@]}"; do
echo $line
RES="$RES\n$(cat $FILE | egrep -i -n "$line" | tr -s " ")"
echo "$line"
RES="$RES\n$(cat "$FILE" | grep -E -i -n "$line" | tr -s " ")"
done

if [ "$RES" ]; then
Expand All @@ -42,11 +43,11 @@ function find_decreases() {
fi
}

echo "\n------------------------------ SUMMARY -------------------------------"
echo "\n⚠️ This filter is here to help spotting changes that should be reviewed carefully."
echo "\n⚠️ It catches only index changes, deletions and value decreases".
printf "\n------------------------------ SUMMARY -------------------------------"
printf "\n⚠️ This filter is here to help spotting changes that should be reviewed carefully."
printf "\n⚠️ It catches only index changes, deletions and value decreases".

find_deletions $FILE
find_index_changes $FILE
find_decreases $FILE
echo "\n----------------------------------------------------------------------\n"
find_deletions "$FILE"
find_index_changes "$FILE"
find_decreases "$FILE"
printf "\n----------------------------------------------------------------------\n"

0 comments on commit f8ea3d2

Please sign in to comment.