#! /bin/sh echo "/* Generated by $0 */" needcomma=0 while read -r line; do [ -z "${line%%#*}" ] && continue # skip comments if [ -n "${line}" -a -z "${line%%:*}" ]; then [ ${needcomma} -eq 1 ] && printf "\"\n\n" type="${line#:}" [ "${type}" = "end" ] && break printf "#define DEFAULT_%s \"%c\n" $(echo "${type}" | tr '[:lower:]' '[:upper:]') '\' needcomma=0 else [ ${needcomma} -eq 1 ] && printf ",%c\n" '\' printf "%s" "${line}" needcomma=1 fi done