Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Swiped md5 code from BDSM

  • Loading branch information...
commit e53db584c823d191f3afe522fc155c28e0296519 1 parent e8a8600
Wayne E. Seguin wayneeseguin authored

Showing 1 changed file with 23 additions and 10 deletions. Show diff stats Hide diff stats

  1. +23 10 scripts/md5
33 scripts/md5
@@ -6,23 +6,36 @@ then
6 6 export rvm_trace_flag
7 7 fi
8 8
9   -args=($*)
10   -file="${args[0]}"
11   -md5="${args[1]}"
12   -args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.
  9 +_archive="${1}"
  10 +shift
13 11
14   -if [[ "$MACHTYPE" =~ darwin ]]
  12 +md5="${1}"
  13 +shift
  14 +
  15 +# Swiped from BDSM
  16 +if command_exists md5
  17 +then
  18 + archive_md5=$(md5 -q "${_archive}")
  19 +elif command_exists md5sum
15 20 then
16   - command="/sbin/md5 -q"
  21 + archive_md5=$(md5sum "${_archive}" | awk '{print $1')
17 22 else
18   - command="md5sum"
  23 + for _path in /sbin /bin /usr/bin /usr/sbin
  24 + do
  25 + if [[ -x "${_path}/md5"]]
  26 + then
  27 + archive_md5=$(${_path}/md5 -q "${_archive}")
  28 + elif [[ -x "${_path}/md5sum"]]
  29 + then
  30 + archive_md5=$(${_path}/md5sum "${_archive}" | awk '{print $1')
  31 + fi
  32 + done
19 33 fi
20 34
21   -file_md5=$($command "$file" | awk '{print $1}')
22   -
23   -if [[ "$file_md5" = "$md5" ]]
  35 +if [[ "${archive_md5}" == "${md5}" ]]
24 36 then
25 37 exit 0
26 38 else
27 39 exit 1
28 40 fi
  41 +

0 comments on commit e53db58

Please sign in to comment.
Something went wrong with that request. Please try again.