See:
* 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.
# Convert CSV to DAT + wrap long lines + remove trailing whitespace
while IFS="${csv_delimiter}" read -r number rule source
do
- printf -- "${title_template}\n" "${number}"
- printf -- "${rule_template}\n" "${rule}"
- printf -- "${source_template}\n" "${source}"
- printf -- "${footer_template}\n"
+ printf -- "${title_template}\\n${rule_template}\\n${source_template}\\n${footer_template}\\n" \
+ "${number}" "${rule}" "${source}"
done < "${infile}" | fold -sw "${line_maxlen}" | sed -e 's/[[:space:]]*$//' > "${outfile}"