#! /bin/sh echo "/* Generated by $0 */" echo "#include \"cmds.h\"" echo "help_t help[] = {" needcomma=0 IFS=" " sed -e 's,["],\\&,g' | while read -r line; do if [ -n "${line}" -a -z "${line%%:*}" ]; then if [ ${needcomma} -eq 1 ]; then printf "\"" [ ${garble} -eq 1 ] && printf ")" printf "},\n" fi line="${line#:}" garble=0 if [ "${line%:}" != "${line}" ]; then garble=1 line="${line%:}" fi type="${line%:*}" cmd="${line#*:}" [ "${cmd}" = "end" ] && break case ${type} in hub) type_flag="HUB" ;; leaf) type_flag="LEAF" ;; *) type_flag="0" ;; esac if [ ${garble} -eq 0 ]; then printf " {%s, \"%s\", 0, \"" ${type_flag} "${cmd}" else printf " {%s, \"%s\", STR(\"" ${type_flag} "${cmd}" fi needcomma=0 else printf "%s\\\n" "${line}" needcomma=1 fi done echo "};"