]> granicus.if.org Git - fortune-mod/commitdiff
Refactoring / code cleanup.
authorShlomi Fish <shlomif@shlomifish.org>
Thu, 10 Mar 2022 06:55:04 +0000 (08:55 +0200)
committerShlomi Fish <shlomif@shlomifish.org>
Thu, 10 Mar 2022 06:55:04 +0000 (08:55 +0200)
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.

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

index 37543a953ce6718cde7cceeb5b41e7d0beece329..c26233761735d817c48346bd5389748711d00270 100644 (file)
@@ -16,15 +16,15 @@ footer_template="%%"
 line_maxlen=78
 
 # Check command line
-if [ $# -ne 2 ]
-then
-       echo "Usage: ${0##*/} INFILE OUTFILE"
-       exit 2
-fi
 infile="$1"
 shift
 outfile="$1"
 shift
+if test "$#" -ne 0
+then
+       echo "Usage: $0 INFILE OUTFILE"
+       exit 2
+fi
 
 # Convert CSV to DAT + wrap long lines + remove trailing whitespace
 while IFS="${csv_delimiter}" read -r number rule source