For conn example, need to handle element 44.45.46.79
For conn example, need to handle element 44.45.46.80
For conn third_example, need to handle element 5.6.7.8
For conn third_example, need to handle element 9.10.11.12
For conn next_example, need to handle element 1.2.3.4
:6+conn_re='[[:space:]]*conn[[:space:]]+([^[:space:]].*)'
:7+rightsource_re='[[:space:]]*(effective)?right(source|subnet)s?=(.*)'
:8+multimatch_re='[{](.*,.*)[}]'
:10+conn=
:12+subnets=()
:12+declare -A subnets
:14+IFS=
:14+read -r line
:14+: 'line=conn example'
:15+[[ conn example =~ [[:space:]]*conn[[:space:]]+([^[:space:]].*) ]]
:15+conn=example
:15+continue
:14+IFS=
:14+read -r line
:14+: 'line= rightsubnets={44.45.46.79/32,44.45.46.80/32}'
:15+[[ rightsubnets={44.45.46.79/32,44.45.46.80/32} =~ [[:space:]]*conn[[:space:]]+([^[:space:]].*) ]]
:16+[[ rightsubnets={44.45.46.79/32,44.45.46.80/32} =~ [[:space:]]*(effective)?right(source|subnet)s?=(.*) ]]
:16+subnets[$conn]='{44.45.46.79/32,44.45.46.80/32}'
:14+IFS=
:14+read -r line
:14+: 'line=conn next_example'
:15+[[ conn next_example =~ [[:space:]]*conn[[:space:]]+([^[:space:]].*) ]]
:15+conn=next_example
:15+continue
:14+IFS=
:14+read -r line
:14+: 'line= rightsubnets=1.2.3.4'
:15+[[ rightsubnets=1.2.3.4 =~ [[:space:]]*conn[[:space:]]+([^[:space:]].*) ]]
:16+[[ rightsubnets=1.2.3.4 =~ [[:space:]]*(effective)?right(source|subnet)s?=(.*) ]]
:16+subnets[$conn]=1.2.3.4
:14+IFS=
:14+read -r line
:14+: 'line=conn third_example'
:15+[[ conn third_example =~ [[:space:]]*conn[[:space:]]+([^[:space:]].*) ]]
:15+conn=third_example
:15+continue
:14+IFS=
:14+read -r line
:14+: 'line= rightsubnets={5.6.7.8,9.10.11.12/32}'
:15+[[ rightsubnets={5.6.7.8,9.10.11.12/32} =~ [[:space:]]*conn[[:space:]]+([^[:space:]].*) ]]
:16+[[ rightsubnets={5.6.7.8,9.10.11.12/32} =~ [[:space:]]*(effective)?right(source|subnet)s?=(.*) ]]
:16+subnets[$conn]='{5.6.7.8,9.10.11.12/32}'
:14+IFS=
:14+read -r line
:18+declare -p subnets
declare -A subnets=([example]="{44.45.46.79/32,44.45.46.80/32}" [third_example]="{5.6.7.8,9.10.11.12/32}" [next_example]="1.2.3.4" )
:26+for conn in "${!subnets[@]}"
:27+: conn=example
:28+rightsource='{44.45.46.79/32,44.45.46.80/32}'
:29+[[ {44.45.46.79/32,44.45.46.80/32} =~ [{](.*,.*)[}] ]]
:30+IFS=,
:30+read -r -a elements
:31+for element in "${elements[@]}"
:32+handle_result example 44.45.46.79/32
:21+local conn=example element=44.45.46.79/32
:22+element=44.45.46.79
:23+echo 'For conn example, need to handle element 44.45.46.79'
:31+for element in "${elements[@]}"
:32+handle_result example 44.45.46.80/32
:21+local conn=example element=44.45.46.80/32
:22+element=44.45.46.80
:23+echo 'For conn example, need to handle element 44.45.46.80'
:26+for conn in "${!subnets[@]}"
:27+: conn=third_example
:28+rightsource='{5.6.7.8,9.10.11.12/32}'
:29+[[ {5.6.7.8,9.10.11.12/32} =~ [{](.*,.*)[}] ]]
:30+IFS=,
:30+read -r -a elements
:31+for element in "${elements[@]}"
:32+handle_result third_example 5.6.7.8
:21+local conn=third_example element=5.6.7.8
:22+element=5.6.7.8
:23+echo 'For conn third_example, need to handle element 5.6.7.8'
:31+for element in "${elements[@]}"
:32+handle_result third_example 9.10.11.12/32
:21+local conn=third_example element=9.10.11.12/32
:22+element=9.10.11.12
:23+echo 'For conn third_example, need to handle element 9.10.11.12'
:26+for conn in "${!subnets[@]}"
:27+: conn=next_example
:28+rightsource=1.2.3.4
:29+[[ 1.2.3.4 =~ [{](.*,.*)[}] ]]
:35+handle_result next_example 1.2.3.4
:21+local conn=next_example element=1.2.3.4
:22+element=1.2.3.4
:23+echo 'For conn next_example, need to handle element 1.2.3.4'