(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_id: Redir_DLess
                  fd: 16777215
                  body: 
                    {
                      (DQ ('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')
                      )
                    }
                  do_expansion: True
                  here_end: EOF
                  was_filled: T
                  spids: [74]
                )
              ]
            )
            (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(0)})
          ]
          spids: [16777215 69]
        )
      ]
      spids: [16777215 93]
    )
    (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: [101 104]
                            )
                          )
                        }
                      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: [122]
                )
              ]
              spids: [120]
            )
            (Assignment
              keyword: Assign_Readonly
              pairs: [(assign_pair lhs:(LhsName name:TARGET) op:Equal rhs:{(SQ )} spids:[128])]
              spids: [126]
            )
          ]
          spids: [16777215 117]
        )
      ]
      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: [138 142]
                  )
                }
              spids: [137]
            )
          ]
          spids: [135]
        )
        (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: [148 151]
                  )
                }
              spids: [147]
            )
          ]
          spids: [145]
        )
      ]
      spids: [132 153]
    )
    (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: [159 163]
              )
            }
          spids: [158]
        )
      ]
      spids: [156]
    )
    (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: [168 172]
              )
            }
          spids: [167]
        )
      ]
      spids: [165]
    )
    (FuncDef
      name: check
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DPipe]
              children: [
                (SimpleCommand
                  words: [{(which)} {($ VSub_Number '$1')}]
                  redirects: [
                    (Redir
                      op_id: Redir_Great
                      fd: 16777215
                      arg_word: {(/dev/null)}
                      spids: [186]
                    )
                  ]
                )
                (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: [192 206]
                )
              ]
            )
          ]
          spids: [179]
        )
      spids: [175 178]
    )
    (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 273]
                )
              ]
              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: [305 309]
                          )
                        }
                      spids: [304]
                    )
                  ]
                  spids: [304]
                )
                (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: [328 344]
                          )
                        }
                      spids: [327]
                    )
                  ]
                  spids: [327]
                )
                (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: [301 436]
            )
          ]
          spids: [215]
        )
      spids: [211 214]
    )
    (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: [454]
                )
              ]
              spids: [454]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(expr)} {(match)} 
                          {
                            (DQ 
                              (CommandSubPart
                                command_list: (CommandList children:[(C {(jekyll)} {(--version)})])
                                left_token: <Left_CommandSub '$('>
                                spids: [467 471]
                              )
                            )
                          } {(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 479]
                )
              ]
              spids: [16777215 507]
            )
            (C {(build_and_serve)})
            (C {(echo)} {(DQ ('Type q to quit, r to rebuild docs and restart jekyll'))})
            (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 560]
                        )
                        (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: [575 593]
                        )
                      ]
                      spids: [16777215 613]
                    )
                  ]
                  spids: [527 616]
                )
            )
          ]
          spids: [445]
        )
      spids: [441 444]
    )
    (FuncDef
      name: cleanup
      body: 
        (BraceGroup
          children: [(C {(rm)} {(-rf)} {($ VSub_Name '$WORKING_DIR')}) (C {(pkill)} {(-9)} {(jekyll)})]
          spids: [625]
        )
      spids: [621 624]
    )
    (C {(trap)} {(cleanup)} {(EXIT)})
    (C {(main)})
  ]
)