Skip to content

Commit

Permalink
Fix shell script warnings reported by shellcheck for scripts/checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
ypid committed Jun 26, 2017
1 parent 8eb3d4f commit 7304988
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scripts/checksum
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
# FIXME
# - the description file is expected to be in the current dir

DESCRIPTIONS=Descriptions.txt
set -o nounset -o pipefail -o errexit

DESCRIPTIONS='Descriptions.txt'

if [ "$1" == "--rm_on_fail" ]; then
RM_ON_FAIL=yes
Expand All @@ -15,30 +17,30 @@ fi

FILE="$1"
if [ -z "$1" ]; then
echo need filename
echo "Need filename" 2>&1
exit 1
fi

LINE=$(egrep "^$FILE " "$DESCRIPTIONS")

if [ $? -ne 0 ]; then
echo "Unknown file $FILE"
echo "Unknown file $FILE" 2>&1
exit 1
fi

if [ ! -e "$FILE" ]; then
echo "File $FILE does not exist"
echo "File $FILE does not exist" 2>&1
exit 1
fi

EXPECT=$(echo "$LINE" | awk -- '{print $2}')
GOT=$(sha1sum "$FILE" | cut -d" " -f1)

if [ "$EXPECT" != "$GOT" ]; then
echo "File $FILE failed checksum check"
echo "File $FILE failed checksum check" 2>&1

if [ "$RM_ON_FAIL" ]; then
rm $FILE
rm "$FILE"
fi

exit 1
Expand Down

0 comments on commit 7304988

Please sign in to comment.