This is Refactoring / code cleanup.
See:
* https://refactoring.com/catalog/extractMethod.html
* https://en.wikipedia.org/wiki/Code_refactoring
* https://www.refactoring.com/
* https://www.joelonsoftware.com/2002/01/23/rub-a-dub-dub/
Some small optimisations may have slipped in as well.
exit 2
fi
+format="${title_template}\\n${rule_template}\\n${source_template}\\n${footer_template}\\n"
+
# Convert CSV to DAT + wrap long lines + remove trailing whitespace
while IFS="${csv_delimiter}" read -r number rule source
do
- printf -- "${title_template}\\n${rule_template}\\n${source_template}\\n${footer_template}\\n" \
- "${number}" "${rule}" "${source}"
+ printf -- "${format}" "${number}" "${rule}" "${source}"
done < "${infile}" | fold -sw "${line_maxlen}" | sed -e 's/[[:space:]]*$//' > "${outfile}"