aboutsummaryrefslogtreecommitdiff
path: root/bin/mkchecksum.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/mkchecksum.sh')
-rwxr-xr-xbin/mkchecksum.sh36
1 files changed, 30 insertions, 6 deletions
diff --git a/bin/mkchecksum.sh b/bin/mkchecksum.sh
index 45f3416..5a7ac1f 100755
--- a/bin/mkchecksum.sh
+++ b/bin/mkchecksum.sh
@@ -2,11 +2,14 @@
main()
{
- if [ -z "$1" ]
- then
- usage
- exit 1
- fi
+ # Handle opts
+ opts "$@"
+ shift "$OPTS"
+ unset OPTS
+
+ # Show help
+ [ "$OPT_HELP_ONLY" ] && usage && exit 0
+ [ -z "$1" ] && usage && exit 1
printf "md5 %s\n" "$(md5sum "$1" | cut -f1 -d" ")"
printf "sha1 %s\n" "$(sha1sum "$1" | cut -f1 -d" ")"
@@ -16,9 +19,30 @@ main()
printf "sha512 %s\n" "$(sha512sum "$1" | cut -f1 -d" ")"
}
+opts()
+{
+ OPTS=0
+
+ while getopts ":h" opt
+ do
+ case "$opt" in
+ h) OPT_HELP_ONLY=1 ;;
+ *)
+ printf "Invalid option passed: %s\n" "$OPTARG" >&2
+ ;;
+ esac
+ done
+}
+
usage()
{
- printf "NYI\n"
+ cat <<EOF
+Usage:
+ $(basename "$0") -h
+ $(basename "$0") <file>
+
+Make a number of checksums of a given file.
+EOF
}
main "$@"