(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:{(SQ )})
                        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: -1
                  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: True
                  spids: [74]
                )
              ]
            )
            (C {(exit)} {(0)})
          ]
          spids: [-1 69]
        )
      ]
      spids: [-1 92]
    )
    (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:{(SQ )})
                              spids: [100 103]
                            )
                          )
                        }
                      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: [121]
                )
              ]
              spids: [119]
            )
            (Assignment
              keyword: Assign_Readonly
              pairs: [(assign_pair lhs:(LhsName name:TARGET) op:Equal rhs:{(SQ )} spids:[127])]
              spids: [125]
            )
          ]
          spids: [-1 116]
        )
      ]
      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: [137 141]
                  )
                }
              spids: [136]
            )
          ]
          spids: [134]
        )
        (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: [147 150]
                  )
                }
              spids: [146]
            )
          ]
          spids: [144]
        )
      ]
      spids: [131 152]
    )
    (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: [158 162]
              )
            }
          spids: [157]
        )
      ]
      spids: [155]
    )
    (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: [167 171]
              )
            }
          spids: [166]
        )
      ]
      spids: [164]
    )
    (FuncDef
      name: check
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [{(which)} {($ VSub_Number "$1")}]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[185])]
                )
                (Subshell
                  child: 
                    (CommandList
                      children: [
                        (Sentence
                          child: 
                            (C {(echo)} 
                              {
                                (DQ ($ VSub_Number "$1") (" not installed. Please install ") 
                                  ($ VSub_Number "$1") (.)
                                )
                              }
                            )
                          terminator: <Op_Semi ";">
                        )
                        (C {(exit)} {(1)})
                      ]
                    )
                  spids: [191 205]
                )
              ]
              op_id: Op_DPipe
            )
          ]
          spids: [178]
        )
      spids: [174 177]
    )
    (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 children:[(C {(pkill)} {(-9)} {(jekyll)})(C {(true)})] op_id:Op_DPipe)
            (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: [-1 272]
                )
              ]
              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: [304 308]
                          )
                        }
                      spids: [303]
                    )
                  ]
                  spids: [303]
                )
                (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: False
                                  )
                                ]
                              )
                            left_token: <Left_CommandSub "$(">
                            spids: [327 343]
                          )
                        }
                      spids: [326]
                    )
                  ]
                  spids: [326]
                )
                (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: False
                )
                (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: False
                )
                (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: [300 435]
            )
          ]
          spids: [214]
        )
      spids: [210 213]
    )
    (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: [453]
                )
              ]
              spids: [453]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(expr)} {(match)} 
                          {
                            (DQ 
                              (CommandSubPart
                                command_list: (CommandList children:[(C {(jekyll)} {(--version)})])
                                left_token: <Left_CommandSub "$(">
                                spids: [466 470]
                              )
                            )
                          } {(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 "\\`">)
                        )
                      }
                    )
                    (C {(exit)} {(1)})
                  ]
                  spids: [-1 478]
                )
              ]
              spids: [-1 506]
            )
            (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))}) (C {(exit)} {(0)})]
                          spids: [-1 559]
                        )
                        (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: [574 592]
                        )
                      ]
                      spids: [-1 612]
                    )
                  ]
                  spids: [526 615]
                )
            )
          ]
          spids: [444]
        )
      spids: [440 443]
    )
    (FuncDef
      name: cleanup
      body: 
        (BraceGroup
          children: [(C {(rm)} {(-rf)} {($ VSub_Name "$WORKING_DIR")}) (C {(pkill)} {(-9)} {(jekyll)})]
          spids: [624]
        )
      spids: [620 623]
    )
    (C {(trap)} {(cleanup)} {(EXIT)})
    (C {(main)})
  ]
)