Started working on converting the regular arrays into an associative array
This commit is contained in:
		
							
								
								
									
										12
									
								
								build.sh
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								build.sh
									
									
									
									
									
								
							| @@ -46,9 +46,19 @@ read_metadata() { | |||||||
| } | } | ||||||
|  |  | ||||||
| convert_to_array() { | 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_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-) | 	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() { | add_date_to_array() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user