Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Swiped md5 code from BDSM

  • Loading branch information...
commit e53db584c823d191f3afe522fc155c28e0296519 1 parent e8a8600
@wayneeseguin wayneeseguin authored
Showing with 23 additions and 10 deletions.
  1. +23 −10 scripts/md5
View
33 scripts/md5
@@ -6,23 +6,36 @@ then
export rvm_trace_flag
fi
-args=($*)
-file="${args[0]}"
-md5="${args[1]}"
-args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.
+_archive="${1}"
+shift
-if [[ "$MACHTYPE" =~ darwin ]]
+md5="${1}"
+shift
+
+# Swiped from BDSM
+if command_exists md5
+then
+ archive_md5=$(md5 -q "${_archive}")
+elif command_exists md5sum
then
- command="/sbin/md5 -q"
+ archive_md5=$(md5sum "${_archive}" | awk '{print $1')
else
- command="md5sum"
+ for _path in /sbin /bin /usr/bin /usr/sbin
+ do
+ if [[ -x "${_path}/md5"]]
+ then
+ archive_md5=$(${_path}/md5 -q "${_archive}")
+ elif [[ -x "${_path}/md5sum"]]
+ then
+ archive_md5=$(${_path}/md5sum "${_archive}" | awk '{print $1')
+ fi
+ done
fi
-file_md5=$($command "$file" | awk '{print $1}')
-
-if [[ "$file_md5" = "$md5" ]]
+if [[ "${archive_md5}" == "${md5}" ]]
then
exit 0
else
exit 1
fi
+
Please sign in to comment.
Something went wrong with that request. Please try again.