#!/bin/sh shell { global c := '////////////////////////////////////////////////////////////////' global skel := 'api-index-skel.txt' sed -e '/^\/\/ table of contents begin/q' $skel echo $c ls api-*.txt | while read filename { matchstr $filename { api-index-skel.txt | api-index.txt { continue } } global title := $[sed -e 1q $filename] global html := "$(filename%.txt).html" echo "* link:$html[$title]" } echo $c sed -n -e '/^\/\/ table of contents end/,$p' $skel } >api-index.txt+ if test -f api-index.txt && cmp api-index.txt api-index.txt+ >/dev/null { rm -f api-index.txt+ } else { mv api-index.txt+ api-index.txt } (CommandList children: [ (Subshell child: (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:c) op: Equal rhs: {(////////////////////////////////////////////////////////////////)} spids: [7] ) ] spids: [7] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:skel) op: Equal rhs: {(api-index-skel.txt)} spids: [11] ) ] spids: [11] ) (C {(sed)} {(-e)} {(SQ <"/^\\/\\/ table of contents begin/q">)} {(DQ ($ VSub_Name "$skel"))}) (C {(echo)} {(DQ ($ VSub_Name "$c"))}) (Pipeline children: [ (C {(ls)} {(api-) (Lit_Other "*") (.txt)}) (While cond: [(C {(read)} {(filename)})] body: (DoGroup children: [ (Case to_match: {(DQ ($ VSub_Name "$filename"))} arms: [ (case_arm pat_list: [{(api-index-skel.txt)} {(api-index.txt)}] action: [(ControlFlow token:)] spids: [64 69 73 -1] ) ] spids: [55 61 76] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:title) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(sed)} {(-e)} {(1q)} {(DQ ($ VSub_Name "$filename"))}) ] ) left_token: spids: [80 90] ) } spids: [79] ) ] spids: [79] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:html) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Percent arg_word:{(.txt)}) spids: [94 98] ) (.html) } spids: [93] ) ] spids: [93] ) (C {(echo)} {(DQ ("* link:") ($ VSub_Name "$html") ("[") ($ VSub_Name "$title") ("]"))} ) ] spids: [52 113] ) ) ] negated: False ) (C {(echo)} {(DQ ($ VSub_Name "$c"))}) (C {(sed)} {(-n)} {(-e)} {(SQ <"/^\\/\\/ table of contents end/,$p">)} {(DQ ($ VSub_Name "$skel"))} ) ] ) redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(api-index.txt) (Lit_Other "+")} spids: [139] ) ] spids: [4 137] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(test)} {(-f)} {(api-index.txt)}) (SimpleCommand words: [{(cmp)} {(api-index.txt)} {(api-index.txt) (Lit_Other "+")}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[161])] ) ] op_id: Op_DAmp ) ] action: [(C {(rm)} {(-f)} {(api-index.txt) (Lit_Other "+")})] spids: [-1 164] ) ] else_action: [(C {(mv)} {(api-index.txt) (Lit_Other "+")} {(api-index.txt)})] spids: [174 184] ) ] )