Commit 8738d193 authored by Jason Karns's avatar Jason Karns
Browse files

Replace associative array w/ variable indirection

Bash 3 doesn't have associative arrays. Use variable indirection to
save various checksum algorithm support results. `printf -v` can save
the output to a variable, whose name is itself stored in a variable
parent 14750a0b
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -246,10 +246,14 @@ compute_md5() {
  fi
}

declare -a HAS_CHECKSUM_SUPPORT
has_checksum_support() {
  local checksum_command="$1"
  return ${HAS_CHECKSUM_SUPPORT[$checksum_command]:=$(echo test | "$checksum_command" >/dev/null; echo $?)}
  local has_checksum_var="HAS_CHECKSUM_SUPPORT_${checksum_command}"

  if [ -z "${!has_checksum_var+defined}" ]; then
    printf -v "$has_checksum_var" "$(echo test | "$checksum_command" >/dev/null; echo $?)"
  fi
  return "${!has_checksum_var}"
}

verify_checksum() {