Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shell script warnings reported by shellcheck for scripts/checksum #34

Merged
merged 1 commit into from
Jun 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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