mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-09-08 10:11:51 +02:00
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
This commit is contained in:
parent
14750a0b93
commit
8738d1935c
1 changed files with 6 additions and 2 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue