data+=("$cur_data")
fi
+verify_data() {
+ local -n record=$1
+
+ for field in ${required_fields[@]}; do
+ if ! [ ${kvp[$field]+a} ]; then
+ exit 1
+ fi
+ done
+
+ exit 0
+}
+
for (( i=0; i<${#data[@]}; i++ )); do
record="${data[$i]}"
declare -A kvp
value=${field#*:}
kvp[$key]=$value
done
- for field in ${required_fields[@]}; do
- if ! [ ${kvp[$field]+a} ]; then
- continue 2
- fi
- done
- valid_count=$((valid_count+1))
+ if ( verify_data kvp ); then
+ valid_count=$((valid_count+1))
+ fi
unset kvp
done
seperator=" "
done
+check_fields() {
+ local -n record=$1
+ for field in ${required_fields[@]}; do
+ if ! [ ${record[$field]+a} ]; then
+ exit 1
+ fi
+ done
+
+ exit 0
+}
+
# on the last line, if cur_data isn't empty, add that to the array
if [ "$cur_data" != "" ]; then
data+=("$cur_data")
value=${field#*:}
kvp[$key]=$value
done
- for field in ${required_fields[@]}; do
- if ! [ ${kvp[$field]+a} ]; then
- continue 2
+ if ( check_fields kvp ); then
+ if ( check_data kvp ); then
+ valid_count=$((valid_count+1))
fi
- done
- if ( check_data kvp ); then
- valid_count=$((valid_count+1))
fi
unset kvp
done