diff options
Diffstat (limited to 'exampleData/ruleSets/buildCombinedRules.sh')
-rwxr-xr-x | exampleData/ruleSets/buildCombinedRules.sh | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/exampleData/ruleSets/buildCombinedRules.sh b/exampleData/ruleSets/buildCombinedRules.sh index 2e442ee..9e74c2f 100755 --- a/exampleData/ruleSets/buildCombinedRules.sh +++ b/exampleData/ruleSets/buildCombinedRules.sh @@ -3,6 +3,9 @@ # This script builds a collection of FiveUI rulesets (contained in various .json files) # into a combined rule sets file: combinedRules.json. # +# Author: Benjamin Jones <bjones@galois.com> +# Copyright 2013 Galois, Inc. +# # For the script to work, the input .json files must have rules separated by # comment lines starting with //---. Also, the last rule in the file must be # followed by //,. See colorRules.json for an example. @@ -23,13 +26,25 @@ function cutend { echo `cat $1 | grep -n '//---' | awk -F ':' {'print $1'} | tail -1` } +### Script ### + cat $HEADER > $OUTFILE -for file in $FILES; do - CUTSTART=`cutstart $file` - CUTEND=`cutend $file` - echo "combining: $file" - cat $file | head -$(($CUTEND-1)) | tail +$CUTSTART \ - | sed 's/\/\/,/,/' >> $OUTFILE +for file in $FILES +do + if [ $file == $OUTFILE ] + then + echo "skipping: $OUTFILE" + else + CUTSTART=`cutstart $file` + CUTEND=`cutend $file` + echo "combining: $file" + echo "// --- included from file: $file --- //" >> $OUTFILE + # cut rules out, change //, -> , and remove single-line comments + cat $file | head -$(($CUTEND-1)) | tail +$CUTSTART \ + | sed 's/\/\/,/,/' \ + | sed 's/\/\/.*$//' \ + >> $OUTFILE + fi done LEN=`wc -l $OUTFILE | awk '{print $1}'` cat $OUTFILE | head -$((LEN-1)) > $TMPFILE |