diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-08-30 10:24:33 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-11-14 05:06:13 +0000 |
commit | 39850473386d39aacf530850751caa013a6d8f0a (patch) | |
tree | 67bbd26cd5823563278df1aea41f0be467437a94 /rules | |
parent | 2a51b6f73b1ae306ae1a5715d9a5f6c24804744b (diff) |
rules: add some comments to the merge.sh file
Let's make this easier to understand for drive-by reviewers. Replace $i with
$partsfile because it's more expressive. And add a comment on what this
actually does.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'rules')
-rwxr-xr-x | rules/merge.sh | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/rules/merge.sh b/rules/merge.sh index b18af7c3..6d15c7e7 100755 --- a/rules/merge.sh +++ b/rules/merge.sh @@ -1,5 +1,7 @@ #!/bin/sh +# Usage: merge.sh <output-file> <file1.part> <file2.part> <file3.part> … + INDIR=`dirname $0` DEST=$1 shift @@ -11,15 +13,23 @@ fi basename=`basename $0` echo "// DO NOT EDIT THIS FILE - IT WAS AUTOGENERATED BY $basename FROM rules/*.part" >$DEST -for i in $*; do - if [ "$i" = "$HDR" ] || [ "$i" = "HDR" ]; then +# The HDR file contains the headers for each section in the rules file. +# This is fed as stdin to the for loop below. +# +# Wherever the current file is the literal string "HDR", read the next line +# from that file append it to $DEST +# Otherwise, take the filename and append it to $DEST. +# + +for partfile in $*; do + if [ "$partfile" = "$HDR" ] || [ "$partfile" = "HDR" ]; then echo >> $DEST; read hdr echo "$hdr" >> $DEST - elif test -f $i; then - cat $i >> $DEST || exit 1 + elif test -f $partfile; then + cat $partfile >> $DEST || exit 1 else - cat $INDIR/$i >> $DEST || exit 1 + cat $INDIR/$partfile >> $DEST || exit 1 fi done < $HDR |