#!/bin/sh echo "/* Automatically generated by $0 */ struct cmdname_help { char name[16]; char help[80]; unsigned char group; }; static const char *common_cmd_groups[] = {" setglobal grps = "grps$Pid.tmp" setglobal match = "match$Pid.tmp" trap "rm -f '$grps' '$match'" 0 1 2 3 15 sed -n ' 1,/^### common groups/b /^### command list/q /^#/b /^[ ]*$/b h;s/^[^ ][^ ]*[ ][ ]*\(.*\)/ N_("\1"),/p g;s/^\([^ ][^ ]*\)[ ].*/\1/w '$grps' ' $1 printf '};\n\n' setglobal n = '0' setglobal substnum = '' while read grp { echo "^git-..*[ ]$grp" setglobal substnum = ""$substnum$(substnum:+;)s/[ ]$grp/$n/"" setglobal n = $shExpr('$n+1') } <"$grps" >"$match" printf 'static struct cmdname_help common_cmds[] = {\n' grep -f $match $1 | sed 's/^git-//' | sort | while read cmd tags { setglobal tag = $[echo $tags | sed "$substnum; s/[^0-9]//g] sed -n ' /^NAME/,/git-'"$cmd"'/H ${ x s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", N_("\1"), '$tag'},/ p }' "Documentation/git-$cmd.txt" } echo "};"