#!/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[] = {" global grps := "grps$Pid.tmp" global 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' global n := '0' global substnum := '' while read grp { echo "^git-..*[ ]$grp" global substnum := ""$substnum$(substnum:+;)s/[ ]$grp/$n/"" global n := $($n+1) } <"$grps" >"$match" printf 'static struct cmdname_help common_cmds[] = {\n' grep -f $match $1 | sed 's/^git-//' | sort | while read cmd tags { global 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 "};" (CommandList children: [ (C {(echo)} { (DQ ("/* Automatically generated by ") ($ VSub_Number "$0") (" */\n") ("struct cmdname_help {\n") ("\tchar name[16];\n") ("\tchar help[80];\n") ("\tunsigned char group;\n") ("};\n") ("\n") ("static const char *common_cmd_groups[] = {") ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:grps) op: Equal rhs: {(grps) ($ VSub_Dollar "$$") (.tmp)} spids: [20] ) ] spids: [20] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:match) op: Equal rhs: {(match) ($ VSub_Dollar "$$") (.tmp)} spids: [25] ) ] spids: [25] ) (C {(trap)} {(DQ ("rm -f '") ($ VSub_Name "$grps") ("' '") ($ VSub_Name "$match") ("'"))} {(0)} {(1)} {(2)} {(3)} {(15)} ) (C {(sed)} {(-n)} { (SQ <"\n"> <"\t1,/^### common groups/b\n"> <"\t/^### command list/q\n"> <"\t/^#/b\n"> <"\t/^[ \t]*$/b\n"> <"\th;s/^[^ \t][^ \t]*[ \t][ \t]*\\(.*\\)/\tN_(\"\\1\"),/p\n"> <"\tg;s/^\\([^ \t][^ \t]*\\)[ \t].*/\\1/w "> ) ($ VSub_Name "$grps") (SQ <"\n"> <"\t">) } {(DQ ($ VSub_Number "$1"))} ) (C {(printf)} {(SQ <"};\\n\\n">)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:n) op:Equal rhs:{(0)} spids:[81])] spids: [81] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:substnum) op:Equal rhs:{(SQ )} spids:[84])] spids: [84] ) (While cond: [(C {(read)} {(grp)})] body: (DoGroup children: [ (C {(echo)} {(DQ ("^git-..*[ \t]") ($ VSub_Name "$grp"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:substnum) op: Equal rhs: { (DQ ($ VSub_Name "$substnum") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonPlus arg_word:{(";")}) spids: [106 110] ) ("s/[ \t]") ($ VSub_Name "$grp") (/) ($ VSub_Name "$n") (/) ) } spids: [103] ) ] spids: [103] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:n) op: Equal rhs: { (ArithSubPart anode: (ArithBinary op_id: Arith_Plus left: (ArithWord w:{($ VSub_Name "$n")}) right: (ArithWord w:{(Lit_Digits 1)}) ) spids: [120 125] ) } spids: [119] ) ] spids: [119] ) ] spids: [92 127] ) redirects: [ (Redir op_id:Redir_Less fd:-1 arg_word:{(DQ ($ VSub_Name "$grps"))} spids:[129]) (Redir op_id:Redir_Great fd:-1 arg_word:{(DQ ($ VSub_Name "$match"))} spids:[134]) ] ) (C {(printf)} {(SQ <"static struct cmdname_help common_cmds[] = {\\n">)}) (Pipeline children: [ (C {(grep)} {(-f)} {(DQ ($ VSub_Name "$match"))} {(DQ ($ VSub_Number "$1"))}) (C {(sed)} {(SQ <"s/^git-//">)}) (C {(sort)}) (While cond: [(C {(read)} {(cmd)} {(tags)})] body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:tag) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_Name "$tags"))}) (C {(sed)} {(DQ ($ VSub_Name "$substnum") ("; s/[^0-9]//g"))}) ] negated: False ) ] ) left_token: spids: [184 199] ) } spids: [183] ) ] spids: [183] ) (C {(sed)} {(-n)} {(SQ <"\n"> <"\t\t/^NAME/,/git-">) (DQ ($ VSub_Name "$cmd")) (SQ <"/H\n"> <"\t\t${\n"> <"\t\t\tx\n"> <"\t\t\ts/.*git-">) (DQ ($ VSub_Name "$cmd")) (SQ <" - \\(.*\\)/\t{\"">) (DQ ($ VSub_Name "$cmd")) (SQ <"\", N_(\"\\1\"), ">) ($ VSub_Name "$tag") (SQ <"},/\n"> <"\t\t\tp\n"> <"\t\t}">) } {(DQ (Documentation/git-) ($ VSub_Name "$cmd") (.txt))} ) ] spids: [180 244] ) ) ] negated: False ) (C {(echo)} {(DQ ("};"))}) ] )