Commit 8738d193 by Jason Karns

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
......@@ -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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment