(CommandList
  children: [
    (C {(set)} {(-eu)})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (C {(Lit_Other '[')} 
                  {
                    (DQ 
                      (BracedVarSub
                        token: <VSub_Number 1>
                        suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(EmptyPart)})
                        spids: [53 56]
                      )
                    )
                  } {(Lit_Other '=') (Lit_Other '=')} {(DQ (help))} {(Lit_Other ']')}
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (SimpleCommand
              words: [{(cat)}]
              redirects: [
                (HereDoc
                  op: <Redir_DLess '<<'>
                  fd: 16777215
                  here_begin: {(EOF)}
                  here_end_span_id: 88
                  stdin_parts: [
                    ('Usage:\n')
                    ($ VSub_Number '$0')
                    (' [port]\n')
                    ('     Builds docs and starts a web server serving docs on localhost:port\n')
                    ('     Default port is 12345.\n')
                    ($ VSub_Number '$0')
                    (' <target directory> [<serving prefix>]\n')
                    ('     Builds docs as static web pages in <target directory>.\n')
                    ('     Replaces absolute paths in the resulting HTML with <serving prefix>,\n')
                    ('     or, if it is not specified, with <target directory>.\n')
                  ]
                )
              ]
            )
            (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(0)})
          ]
          spids: [16777215 69]
        )
      ]
      spids: [16777215 94]
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (DBracket
                  expr: 
                    (BoolBinary
                      op_id: BoolBinary_GlobDEqual
                      left: 
                        {
                          (DQ 
                            (BracedVarSub
                              token: <VSub_Number 1>
                              suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(EmptyPart)})
                              spids: [102 105]
                            )
                          )
                        }
                      right: {(Lit_Other '[') (0-9) (Lit_Other ']') (Lit_Other '*')}
                    )
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (Assignment
              keyword: Assign_Readonly
              pairs: [
                (assign_pair
                  lhs: (LhsName name:PORT)
                  op: Equal
                  rhs: {($ VSub_Number '$1')}
                  spids: [123]
                )
              ]
              spids: [121]
            )
            (Assignment
              keyword: Assign_Readonly
              pairs: [(assign_pair lhs:(LhsName name:TARGET) op:Equal rhs:{(SQ )} spids:[129])]
              spids: [127]
            )
          ]
          spids: [16777215 118]
        )
      ]
      else_action: [
        (Assignment
          keyword: Assign_Readonly
          pairs: [
            (assign_pair
              lhs: (LhsName name:PORT)
              op: Equal
              rhs: 
                {
                  (BracedVarSub
                    token: <VSub_Number 1>
                    suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(12345)})
                    spids: [139 143]
                  )
                }
              spids: [138]
            )
          ]
          spids: [136]
        )
        (Assignment
          keyword: Assign_Readonly
          pairs: [
            (assign_pair
              lhs: (LhsName name:TARGET)
              op: Equal
              rhs: 
                {
                  (BracedVarSub
                    token: <VSub_Number 1>
                    suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{})
                    spids: [149 152]
                  )
                }
              spids: [148]
            )
          ]
          spids: [146]
        )
      ]
      spids: [133 154]
    )
    (Assignment
      keyword: Assign_Readonly
      pairs: [
        (assign_pair
          lhs: (LhsName name:WORKING_DIR)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: (CommandList children:[(C {(mktemp)} {(-d)})])
                left_token: <Left_CommandSub '$('>
                spids: [160 164]
              )
            }
          spids: [159]
        )
      ]
      spids: [157]
    )
    (Assignment
      keyword: Assign_Readonly
      pairs: [
        (assign_pair
          lhs: (LhsName name:SERVING_PREFIX)
          op: Equal
          rhs: 
            {
              (BracedVarSub
                token: <VSub_Number 2>
                suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{($ VSub_Name '$TARGET')})
                spids: [169 173]
              )
            }
          spids: [168]
        )
      ]
      spids: [166]
    )
    (FuncDef
      name: check
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DPipe]
              children: [
                (SimpleCommand
                  words: [{(which)} {($ VSub_Number '$1')}]
                  redirects: [(Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})]
                )
                (Subshell
                  child: 
                    (CommandList
                      children: [
                        (Sentence
                          child: 
                            (C {(echo)} 
                              {
                                (DQ ($ VSub_Number '$1') (' not installed. Please install ') 
                                  ($ VSub_Number '$1') (.)
                                )
                              }
                            )
                          terminator: <Op_Semi ';'>
                        )
                        (ControlFlow
                          token: <ControlFlow_Exit exit>
                          arg_word: {(1)}
                        )
                      ]
                    )
                  spids: [193 207]
                )
              ]
            )
          ]
          spids: [180]
        )
      spids: [176 179]
    )
    (FuncDef
      name: build_and_serve
      body: 
        (BraceGroup
          children: [
            (C {(bazel)} {(build)} {(//site) (Lit_Other ':') (jekyll-tree.tar)})
            (C {(rm)} {(-rf)} {($ VSub_Name '$WORKING_DIR') (/) (Lit_Other '*')})
            (C {(tar)} {(-xf)} {(bazel-genfiles/site/jekyll-tree.tar)} {(-C)} 
              {($ VSub_Name '$WORKING_DIR')}
            )
            (AndOr
              ops: [Op_DPipe]
              children: [(C {(pkill)} {(-9)} {(jekyll)}) (C {(true)})]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other '[')} {(-z)} {(DQ ($ VSub_Name '$TARGET'))} {(Lit_Other ']')})
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} {(DQ ('Serving bazel.build site at port ') ($ VSub_Name '$PORT'))})
                    (C {(jekyll)} {(serve)} {(--detach)} {(--quiet)} {(--port)} {($ VSub_Name '$PORT')} 
                      {(--source)} {($ VSub_Name '$WORKING_DIR')}
                    )
                  ]
                  spids: [16777215 274]
                )
              ]
              else_action: [
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:TMP_TARGET)
                      op: Equal
                      rhs: 
                        {
                          (CommandSubPart
                            command_list: (CommandList children:[(C {(mktemp)} {(-d)})])
                            left_token: <Left_CommandSub '$('>
                            spids: [306 310]
                          )
                        }
                      spids: [305]
                    )
                  ]
                  spids: [305]
                )
                (C {(jekyll)} {(build)} {(--source)} {($ VSub_Name '$WORKING_DIR')} {(--destination)} 
                  {(DQ ($ VSub_Name '$TMP_TARGET'))}
                )
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:REPLACEMENT)
                      op: Equal
                      rhs: 
                        {
                          (CommandSubPart
                            command_list: 
                              (CommandList
                                children: [
                                  (Pipeline
                                    children: [
                                      (C {(echo)} {($ VSub_Name '$SERVING_PREFIX')})
                                      (C {(sed)} 
                                        {(s/) (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) 
                                          (//) (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) 
                                          (EscapedLiteralPart
                                            token: <Lit_EscapedChar '\\\\'>
                                          ) (//g)
                                        }
                                      )
                                    ]
                                    negated: F
                                  )
                                ]
                              )
                            left_token: <Left_CommandSub '$('>
                            spids: [329 345]
                          )
                        }
                      spids: [328]
                    )
                  ]
                  spids: [328]
                )
                (Pipeline
                  children: [
                    (C {(find)} {($ VSub_Name '$TMP_TARGET')} {(-name)} {(SQ <'*.html'>)})
                    (C {(xargs)} {(sed)} {(-i)} 
                      {(s/href) (Lit_Other '=') (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) 
                        (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) (//href) (Lit_Other '=') 
                        (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ($ VSub_Name '$REPLACEMENT') (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) (//g)
                      }
                    )
                  ]
                  negated: F
                )
                (Pipeline
                  children: [
                    (C {(find)} {($ VSub_Name '$TMP_TARGET')} {(-name)} {(SQ <'*.html'>)})
                    (C {(xargs)} {(sed)} {(-i)} 
                      {(s/src) (Lit_Other '=') (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) 
                        (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) (//src) (Lit_Other '=') 
                        (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ($ VSub_Name '$REPLACEMENT') (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) (//g)
                      }
                    )
                  ]
                  negated: F
                )
                (C {(cp)} {(-R)} {($ VSub_Name '$TMP_TARGET') (/) (Lit_Other '*')} 
                  {($ VSub_Name '$TARGET')}
                )
                (C {(echo)} {(DQ ('Static pages copied to ') ($ VSub_Name '$TARGET'))})
                (C {(echo)} {(DQ ('Should be served from ') ($ VSub_Name '$SERVING_PREFIX'))})
              ]
              spids: [302 437]
            )
          ]
          spids: [216]
        )
      spids: [212 215]
    )
    (FuncDef
      name: main
      body: 
        (BraceGroup
          children: [
            (C {(check)} {(jekyll)})
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:old_version)
                  op: Equal
                  rhs: {(DQ ('Jekyll 0.11.2'))}
                  spids: [455]
                )
              ]
              spids: [455]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(expr)} {(match)} 
                          {
                            (DQ 
                              (CommandSubPart
                                command_list: (CommandList children:[(C {(jekyll)} {(--version)})])
                                left_token: <Left_CommandSub '$('>
                                spids: [468 472]
                              )
                            )
                          } {(DQ ($ VSub_Name '$old_version'))}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (C {(echo)} {(DQ ('ERROR: Running with an old version of Jekyll, update '))} 
                      {
                        (DQ ('to 2.5.3 with ') (EscapedLiteralPart token:<Lit_EscapedChar '\\`'>) 
                          ('sudo gem install jekyll -v 2.5.3') (EscapedLiteralPart token:<Lit_EscapedChar '\\`'>)
                        )
                      }
                    )
                    (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
                  ]
                  spids: [16777215 480]
                )
              ]
              spids: [16777215 508]
            )
            (C {(build_and_serve)})
            (C {(echo)} {(DQ ('Type q to quit, r to rebuild docs and restart jekyll'))})
            (WhileUntil
              keyword: <KW_While while>
              cond: [(Sentence child:(C {(true)}) terminator:<Op_Semi ';'>)]
              body: 
                (DoGroup
                  children: [
                    (C {(read)} {(-n)} {(1)} {(-s)} {(user_input)})
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other '[')} {(DQ ($ VSub_Name '$user_input'))} 
                                  {(Lit_Other '=') (Lit_Other '=')} {(DQ (q))} {(Lit_Other ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [
                            (C {(echo)} {(DQ (Quitting))})
                            (ControlFlow
                              token: <ControlFlow_Exit exit>
                              arg_word: {(0)}
                            )
                          ]
                          spids: [16777215 561]
                        )
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other '[')} {(DQ ($ VSub_Name '$user_input'))} 
                                  {(Lit_Other '=') (Lit_Other '=')} {(DQ (r))} {(Lit_Other ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [
                            (C {(echo)} {(DQ ('Rebuilding docs and restarting jekyll'))})
                            (C {(build_and_serve)})
                            (C {(echo)} {(DQ ('Rebuilt docs and restarted jekyll'))})
                          ]
                          spids: [576 594]
                        )
                      ]
                      spids: [16777215 614]
                    )
                  ]
                  spids: [528 617]
                )
            )
          ]
          spids: [446]
        )
      spids: [442 445]
    )
    (FuncDef
      name: cleanup
      body: 
        (BraceGroup
          children: [(C {(rm)} {(-rf)} {($ VSub_Name '$WORKING_DIR')}) (C {(pkill)} {(-9)} {(jekyll)})]
          spids: [626]
        )
      spids: [622 625]
    )
    (C {(trap)} {(cleanup)} {(EXIT)})
    (C {(main)})
  ]
)