1#!/bin/bash
2
3# Features Content Interface Mods Balance Bugfixes Performance Infrastructure Build I18N
4
5while read -r category description; do
6    if [ -z "$category" ] || [[ "*" == "$category" ]] || [[ $( expr $category : "2019" ) == 4 ]] ; then
7        continue
8    fi
9    category=${category,,}
10    category=${category^}
11    if [[ "$category" == "I18n" ]] ; then
12        category="I18N and A11Y"
13    fi
14    found_category=""
15    inserted=""
16    while read -r line; do
17        if [ -z "$found_category" ]; then
18            if [[ "$line" == "## $category:" ]] ; then
19                found_category="true"
20            fi
21        elif [ -z "$inserted" ] && [ "$line" == "" ]; then
22            inserted="true"
23            echo "$description" >> tmpfile
24        fi
25        echo "$line" >> tmpfile;
26    done < "$2"
27    if [ -z "$found_category" ]; then
28	echo "couldn't find category $category"
29    fi
30    if [ -z "$inserted" ]; then
31	echo "couldn't insert $category $description"
32    fi
33    mv tmpfile $2
34done < "$1"
35