diff --git a/build.sh b/build.sh index 247ff4c..1a2b2c5 100755 --- a/build.sh +++ b/build.sh @@ -46,9 +46,19 @@ read_metadata() { } convert_to_array() { -# Converts the metadata into two arrays: one with the key, and the other with the value +# Converts the metadata into two arrays: one with the key, and the other with the value. readarray -t meta_key < <(echo -e "$1" | awk -F: '{print $1}') readarray -t meta_value < <(echo -e "$1" | awk -F: '{st = index($0,":"); values = substr($0,st+1); print values}' | cut -c 2-) + +# Merge both arrays into an associative array + declare -A meta_array + for index in $(seq 0 `expr "${#meta_key[@]}" - 1`); do + meta_array["${meta_key[$index]}"]="${meta_value[$index]}" + done + +# for array_key in "${!meta_array[@]}"; do +# printf "[%s] = %s\n" "$array_key" "${meta_array[$array_key]}" +# done } add_date_to_array() {