Skip to content

Commit f096142

Browse files
committed
Extract a common expression into a variable/const.
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.
1 parent 122c348 commit f096142

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fortune-mod/datfiles/data/rules-of-acquisition-gen.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ then
2626
exit 2
2727
fi
2828

29+
format="${title_template}\\n${rule_template}\\n${source_template}\\n${footer_template}\\n"
30+
2931
# Convert CSV to DAT + wrap long lines + remove trailing whitespace
3032
while IFS="${csv_delimiter}" read -r number rule source
3133
do
32-
printf -- "${title_template}\\n${rule_template}\\n${source_template}\\n${footer_template}\\n" \
33-
"${number}" "${rule}" "${source}"
34+
printf -- "${format}" "${number}" "${rule}" "${source}"
3435
done < "${infile}" | fold -sw "${line_maxlen}" | sed -e 's/[[:space:]]*$//' > "${outfile}"

0 commit comments

Comments
 (0)