(command.CommandList
  children: [
    (C {(Id.KW_Set set)} {(-eu)})
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {(Id.Lit_LBracket '[')} 
                  {
                    (DQ 
                      (braced_var_sub
                        token: (Token id:Id.VSub_Number val:1 span_id:54)
                        suffix_op: (suffix_op.Unary op_id:Id.VTest_Hyphen arg_word:(word.Empty))
                      )
                    )
                  } {(Id.Lit_Equals '=') (Id.Lit_Equals '=')} {(DQ (help))} {(Id.Lit_RBracket ']')}
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:67)
            )
          ]
          action: [
            (command.Simple
              words: [{(cat)}]
              redirects: [
                (redir.HereDoc
                  op: (Token id:Id.Redir_DLess val:'<<' span_id:74)
                  fd: -1
                  here_begin: {(EOF)}
                  here_end_span_id: 88
                  stdin_parts: [
                    ('Usage:\n')
                    ($ Id.VSub_Number '$0')
                    (' [port]\n')
                    ('     Builds docs and starts a web server serving docs on localhost:port\n')
                    ('     Default port is 12345.\n')
                    ($ Id.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')
                  ]
                )
              ]
            )
            (command.ControlFlow
              token: (Token id:Id.ControlFlow_Exit val:exit span_id:90)
              arg_word: {(0)}
            )
          ]
          spids: [48 69]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_GlobDEqual
                      left: 
                        {
                          (DQ 
                            (braced_var_sub
                              token: (Token id:Id.VSub_Number val:1 span_id:103)
                              suffix_op: (suffix_op.Unary op_id:Id.VTest_Hyphen arg_word:(word.Empty))
                            )
                          )
                        }
                      right: {(Id.Lit_Other '[') (0-9) (Id.Lit_Other ']') (Id.Lit_Other '*')}
                    )
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:116)
            )
          ]
          action: [
            (C {(readonly)} {(Id.Lit_VarLike 'PORT=') ($ Id.VSub_Number '$1')})
            (C {(readonly)} {(Id.Lit_VarLike 'TARGET=') (SQ )})
          ]
          spids: [97 118]
        )
      ]
      else_action: [
        (C {(readonly)} 
          {(Id.Lit_VarLike 'PORT=') 
            (braced_var_sub
              token: (Token id:Id.VSub_Number val:1 span_id:140)
              suffix_op: (suffix_op.Unary op_id:Id.VTest_Hyphen arg_word:{(12345)})
            )
          }
        )
        (C {(readonly)} 
          {(Id.Lit_VarLike 'TARGET=') 
            (braced_var_sub
              token: (Token id:Id.VSub_Number val:1 span_id:150)
              suffix_op: (suffix_op.Unary op_id:Id.VTest_Hyphen arg_word:{})
            )
          }
        )
      ]
    )
    (C {(readonly)} 
      {(Id.Lit_VarLike 'WORKING_DIR=') 
        (command_sub
          left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:160)
          command_list: (command.CommandList children:[(C {(mktemp)} {(-d)})])
        )
      }
    )
    (C {(readonly)} 
      {(Id.Lit_VarLike 'SERVING_PREFIX=') 
        (braced_var_sub
          token: (Token id:Id.VSub_Number val:2 span_id:170)
          suffix_op: 
            (suffix_op.Unary
              op_id: Id.VTest_Hyphen
              arg_word: {($ Id.VSub_DollarName '$TARGET')}
            )
        )
      }
    )
    (command.ShFunction
      name: check
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (command.Simple
                  words: [{(which)} {($ Id.VSub_Number '$1')}]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_Great val:'>' span_id:187)
                      fd: -1
                      arg_word: {(/dev/null)}
                    )
                  ]
                )
                (command.Subshell
                  command_list: 
                    (command.CommandList
                      children: [
                        (command.Sentence
                          child: 
                            (C {(echo)} 
                              {
                                (DQ ($ Id.VSub_Number '$1') (' not installed. Please install ') 
                                  ($ Id.VSub_Number '$1') (.)
                                )
                              }
                            )
                          terminator: (Token id:Id.Op_Semi val:';' span_id:202)
                        )
                        (command.ControlFlow
                          token: (Token id:Id.ControlFlow_Exit val:exit span_id:204)
                          arg_word: {(1)}
                        )
                      ]
                    )
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: build_and_serve
      body: 
        (command.BraceGroup
          children: [
            (C {(bazel)} {(build)} {(//site) (Id.Lit_Other ':') (jekyll-tree.tar)})
            (C {(rm)} {(-rf)} {($ Id.VSub_DollarName '$WORKING_DIR') (/) (Id.Lit_Star '*')})
            (C {(tar)} {(-xf)} {(bazel-genfiles/site/jekyll-tree.tar)} {(-C)} 
              {($ Id.VSub_DollarName '$WORKING_DIR')}
            )
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [(C {(pkill)} {(-9)} {(jekyll)}) (C {(true)})]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Id.Lit_LBracket '[')} {(-z)} {(DQ ($ Id.VSub_DollarName '$TARGET'))} 
                          {(Id.Lit_RBracket ']')}
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:272)
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {(DQ ('Serving bazel.build site at port ') ($ Id.VSub_DollarName '$PORT'))}
                    )
                    (C {(jekyll)} {(serve)} {(--detach)} {(--quiet)} {(--port)} 
                      {($ Id.VSub_DollarName '$PORT')} {(--source)} {($ Id.VSub_DollarName '$WORKING_DIR')}
                    )
                  ]
                  spids: [261 274]
                )
              ]
              else_action: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:TMP_TARGET)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:306)
                            command_list: (command.CommandList children:[(C {(mktemp)} {(-d)})])
                          )
                        }
                      spids: [305]
                    )
                  ]
                )
                (C {(jekyll)} {(build)} {(--source)} {($ Id.VSub_DollarName '$WORKING_DIR')} 
                  {(--destination)} {(DQ ($ Id.VSub_DollarName '$TMP_TARGET'))}
                )
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:REPLACEMENT)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:329)
                            command_list: 
                              (command.CommandList
                                children: [
                                  (command.Pipeline
                                    children: [
                                      (C {(echo)} {($ Id.VSub_DollarName '$SERVING_PREFIX')})
                                      (C {(sed)} 
                                        {(s/) 
                                          (word_part.EscapedLiteral
                                            token: 
                                              (Token
                                                id: Id.Lit_EscapedChar
                                                val: '\\\\'
                                                span_id: 339
                                              )
                                          ) (//) (word_part.EscapedLiteral token:(Token id:Id.Lit_EscapedChar val:'\\\\' span_id:341)) 
                                          (word_part.EscapedLiteral
                                            token: 
                                              (Token
                                                id: Id.Lit_EscapedChar
                                                val: '\\\\'
                                                span_id: 342
                                              )
                                          ) (word_part.EscapedLiteral token:(Token id:Id.Lit_EscapedChar val:'\\\\' span_id:343)) (//g)
                                        }
                                      )
                                    ]
                                    negated: F
                                  )
                                ]
                              )
                          )
                        }
                      spids: [328]
                    )
                  ]
                )
                (command.Pipeline
                  children: [
                    (C {(find)} {($ Id.VSub_DollarName '$TMP_TARGET')} {(-name)} 
                      {(SQ (Token id:Id.Lit_Chars val:'*.html' span_id:355))}
                    )
                    (C {(xargs)} {(sed)} {(-i)} 
                      {(s/href) (Id.Lit_Equals '=') 
                        (word_part.EscapedLiteral
                          token: (Token id:Id.Lit_EscapedChar val:'\\\\' span_id:368)
                        ) (word_part.EscapedLiteral token:(Token id:Id.Lit_EscapedChar val:'\\"' span_id:369)) 
                        (word_part.EscapedLiteral
                          token: (Token id:Id.Lit_EscapedChar val:'\\\\' span_id:370)
                        ) (//href) (Id.Lit_Equals '=') 
                        (word_part.EscapedLiteral
                          token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:373)
                        ) ($ Id.VSub_DollarName '$REPLACEMENT') 
                        (word_part.EscapedLiteral
                          token: (Token id:Id.Lit_EscapedChar val:'\\\\' span_id:375)
                        ) (//g)
                      }
                    )
                  ]
                  negated: F
                )
                (command.Pipeline
                  children: [
                    (C {(find)} {($ Id.VSub_DollarName '$TMP_TARGET')} {(-name)} 
                      {(SQ (Token id:Id.Lit_Chars val:'*.html' span_id:386))}
                    )
                    (C {(xargs)} {(sed)} {(-i)} 
                      {(s/src) (Id.Lit_Equals '=') 
                        (word_part.EscapedLiteral
                          token: (Token id:Id.Lit_EscapedChar val:'\\\\' span_id:399)
                        ) (word_part.EscapedLiteral token:(Token id:Id.Lit_EscapedChar val:'\\"' span_id:400)) 
                        (word_part.EscapedLiteral
                          token: (Token id:Id.Lit_EscapedChar val:'\\\\' span_id:401)
                        ) (//src) (Id.Lit_Equals '=') 
                        (word_part.EscapedLiteral
                          token: (Token id:Id.Lit_EscapedChar val:'\\"' span_id:404)
                        ) ($ Id.VSub_DollarName '$REPLACEMENT') 
                        (word_part.EscapedLiteral
                          token: (Token id:Id.Lit_EscapedChar val:'\\\\' span_id:406)
                        ) (//g)
                      }
                    )
                  ]
                  negated: F
                )
                (C {(cp)} {(-R)} {($ Id.VSub_DollarName '$TMP_TARGET') (/) (Id.Lit_Star '*')} 
                  {($ Id.VSub_DollarName '$TARGET')}
                )
                (C {(echo)} {(DQ ('Static pages copied to ') ($ Id.VSub_DollarName '$TARGET'))})
                (C {(echo)} {(DQ ('Should be served from ') ($ Id.VSub_DollarName '$SERVING_PREFIX'))})
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: main
      body: 
        (command.BraceGroup
          children: [
            (C {(check)} {(jekyll)})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:old_version)
                  op: assign_op.Equal
                  rhs: {(DQ ('Jekyll 0.11.2'))}
                  spids: [455]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(expr)} {(match)} 
                          {
                            (DQ 
                              (command_sub
                                left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:468)
                                command_list: 
                                  (command.CommandList
                                    children: [(C {(jekyll)} {(--version)})]
                                  )
                              )
                            )
                          } {(DQ ($ Id.VSub_DollarName '$old_version'))}
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:478)
                    )
                  ]
                  action: [
                    (C {(echo)} {(DQ ('ERROR: Running with an old version of Jekyll, update '))} 
                      {
                        (DQ ('to 2.5.3 with ') 
                          (word_part.EscapedLiteral
                            token: (Token id:Id.Lit_EscapedChar val:'\\`' span_id:497)
                          ) ('sudo gem install jekyll -v 2.5.3') 
                          (word_part.EscapedLiteral
                            token: (Token id:Id.Lit_EscapedChar val:'\\`' span_id:499)
                          )
                        )
                      }
                    )
                    (command.ControlFlow
                      token: (Token id:Id.ControlFlow_Exit val:exit span_id:503)
                      arg_word: {(1)}
                    )
                  ]
                  spids: [461 480]
                )
              ]
            )
            (C {(build_and_serve)})
            (C {(echo)} {(DQ ('Type q to quit, r to rebuild docs and restart jekyll'))})
            (command.WhileUntil
              keyword: (Token id:Id.KW_While val:while span_id:523)
              cond: [
                (command.Sentence
                  child: (C {(true)})
                  terminator: (Token id:Id.Op_Semi val:';' span_id:526)
                )
              ]
              body: 
                (command.DoGroup
                  children: [
                    (C {(read)} {(-n)} {(1)} {(-s)} {(user_input)})
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (C {(Id.Lit_LBracket '[')} {(DQ ($ Id.VSub_DollarName '$user_input'))} 
                                  {(Id.Lit_Equals '=') (Id.Lit_Equals '=')} {(DQ (q))} {(Id.Lit_RBracket ']')}
                                )
                              terminator: (Token id:Id.Op_Semi val:';' span_id:559)
                            )
                          ]
                          action: [
                            (C {(echo)} {(DQ (Quitting))})
                            (command.ControlFlow
                              token: (Token id:Id.ControlFlow_Exit val:exit span_id:571)
                              arg_word: {(0)}
                            )
                          ]
                          spids: [543 561]
                        )
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (C {(Id.Lit_LBracket '[')} {(DQ ($ Id.VSub_DollarName '$user_input'))} 
                                  {(Id.Lit_Equals '=') (Id.Lit_Equals '=')} {(DQ (r))} {(Id.Lit_RBracket ']')}
                                )
                              terminator: (Token id:Id.Op_Semi val:';' span_id:592)
                            )
                          ]
                          action: [
                            (C {(echo)} {(DQ ('Rebuilding docs and restarting jekyll'))})
                            (C {(build_and_serve)})
                            (C {(echo)} {(DQ ('Rebuilt docs and restarted jekyll'))})
                          ]
                          spids: [576 594]
                        )
                      ]
                    )
                  ]
                )
            )
          ]
        )
    )
    (command.ShFunction
      name: cleanup
      body: 
        (command.BraceGroup
          children: [
            (C {(rm)} {(-rf)} {($ Id.VSub_DollarName '$WORKING_DIR')})
            (C {(pkill)} {(-9)} {(jekyll)})
          ]
        )
    )
    (C {(trap)} {(cleanup)} {(EXIT)})
    (C {(main)})
  ]
)