(command.CommandList
  children: [
    (C {<set>} {<-eu>})
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (C {<Id.Lit_LBracket '['>} 
                      {
                        (DQ 
                          (braced_var_sub
                            token: <Id.VSub_Number 1>
                            suffix_op: (suffix_op.Unary tok:<Id.VTest_Hyphen -> arg_word:(word.Empty))
                          )
                        )
                      } {<Id.Lit_Equals '='> <Id.Lit_Equals '='>} {(DQ <help>)} {<Id.Lit_RBracket ']'>}
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      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'>
                      ]
                    )
                )
              ]
              do_fork: T
            )
            (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<0>})
          ]
          spids: [48 69]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (command.DBracket
                      expr: 
                        (bool_expr.Binary
                          op_id: Id.BoolBinary_GlobDEqual
                          left: 
                            {
                              (DQ 
                                (braced_var_sub
                                  token: <Id.VSub_Number 1>
                                  suffix_op: (suffix_op.Unary tok:<Id.VTest_Hyphen -> arg_word:(word.Empty))
                                )
                              )
                            }
                          right: {<Id.Lit_Other '['> <0-9> <Id.Lit_Other ']'> <Id.Lit_Other '*'>}
                        )
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          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: <Id.VSub_Number 1>
              suffix_op: (suffix_op.Unary tok:<Id.VTest_Hyphen -> arg_word:{<12345>})
            )
          }
        )
        (C {<readonly>} 
          {<Id.Lit_VarLike 'TARGET='> 
            (braced_var_sub
              token: <Id.VSub_Number 1>
              suffix_op: (suffix_op.Unary tok:<Id.VTest_Hyphen -> arg_word:{})
            )
          }
        )
      ]
    )
    (C {<readonly>} 
      {<Id.Lit_VarLike 'WORKING_DIR='> 
        (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<mktemp>} {<-d>}))
      }
    )
    (C {<readonly>} 
      {<Id.Lit_VarLike 'SERVING_PREFIX='> 
        (braced_var_sub
          token: <Id.VSub_Number 2>
          suffix_op: 
            (suffix_op.Unary
              tok: <Id.VTest_Hyphen ->
              arg_word: {($ Id.VSub_DollarName '$TARGET')}
            )
        )
      }
    )
    (command.ShFunction
      name: check
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (command.Simple
                  words: [{<which>} {($ Id.VSub_Number '$1')}]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<'/dev/null'>}
                    )
                  ]
                  do_fork: T
                )
                (command.Subshell
                  child: 
                    (command.CommandList
                      children: [
                        (command.Sentence
                          child: 
                            (C {<echo>} 
                              {
                                (DQ ($ Id.VSub_Number '$1') <' not installed. Please install '> 
                                  ($ Id.VSub_Number '$1') <.>
                                )
                              }
                            )
                          terminator: <Id.Op_Semi _>
                        )
                        (command.ControlFlow
                          token: <Id.ControlFlow_Exit exit>
                          arg_word: {<1>}
                        )
                      ]
                    )
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: build_and_serve
      body: 
        (BraceGroup
          children: [
            (C {<bazel>} {<build>} {<'//site'> <Id.Lit_Colon ':'> <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: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ ($ Id.VSub_DollarName '$TARGET'))} 
                              {<Id.Lit_RBracket ']'>}
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  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: <Id.Left_DollarParen '$('>
                            child: (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: <Id.Left_DollarParen '$('>
                            child: 
                              (command.Pipeline
                                children: [
                                  (C {<echo>} {($ Id.VSub_DollarName '$SERVING_PREFIX')})
                                  (C {<sed>} 
                                    {<'s/'> 
                                      (word_part.EscapedLiteral
                                        token: <Id.Lit_EscapedChar '\\\\'>
                                      ) <'//'> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) 
                                      (word_part.EscapedLiteral
                                        token: <Id.Lit_EscapedChar '\\\\'>
                                      ) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) <'//g'>
                                    }
                                  )
                                ]
                                negated: F
                              )
                          )
                        }
                      spids: [328]
                    )
                  ]
                )
                (command.Pipeline
                  children: [
                    (C {<find>} {($ Id.VSub_DollarName '$TMP_TARGET')} {<-name>} {(SQ <'*.html'>)})
                    (C {<xargs>} {<sed>} {<-i>} 
                      {<'s/href'> <Id.Lit_Equals '='> 
                        (word_part.EscapedLiteral
                          token: <Id.Lit_EscapedChar '\\\\'>
                        ) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
                        (word_part.EscapedLiteral
                          token: <Id.Lit_EscapedChar '\\\\'>
                        ) <'//href'> <Id.Lit_Equals '='> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
                        ($ Id.VSub_DollarName '$REPLACEMENT') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) <'//g'>
                      }
                    )
                  ]
                  negated: F
                )
                (command.Pipeline
                  children: [
                    (C {<find>} {($ Id.VSub_DollarName '$TMP_TARGET')} {<-name>} {(SQ <'*.html'>)})
                    (C {<xargs>} {<sed>} {<-i>} 
                      {<'s/src'> <Id.Lit_Equals '='> 
                        (word_part.EscapedLiteral
                          token: <Id.Lit_EscapedChar '\\\\'>
                        ) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
                        (word_part.EscapedLiteral
                          token: <Id.Lit_EscapedChar '\\\\'>
                        ) <'//src'> <Id.Lit_Equals '='> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
                        ($ Id.VSub_DollarName '$REPLACEMENT') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) <'//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: 
        (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: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<expr>} {<match>} 
                              {
                                (DQ 
                                  (command_sub
                                    left_token: <Id.Left_DollarParen '$('>
                                    child: (C {<jekyll>} {<--version>})
                                  )
                                )
                              } {(DQ ($ Id.VSub_DollarName '$old_version'))}
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (C {<echo>} {(DQ <'ERROR: Running with an old version of Jekyll, update '>)} 
                      {
                        (DQ <'to 2.5.3 with '> 
                          (word_part.EscapedLiteral
                            token: <Id.Lit_EscapedChar '\\`'>
                          ) <'sudo gem install jekyll -v 2.5.3'> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\`'>)
                        )
                      }
                    )
                    (command.ControlFlow
                      token: <Id.ControlFlow_Exit exit>
                      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: <Id.KW_While while>
              cond: 
                (condition.Shell
                  commands: [(command.Sentence child:(C {<true>}) terminator:<Id.Op_Semi _>)]
                )
              body: 
                (command.DoGroup
                  children: [
                    (C {<read>} {<-n>} {<1>} {<-s>} {<user_input>})
                    (command.If
                      arms: [
                        (if_arm
                          cond: 
                            (condition.Shell
                              commands: [
                                (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: <Id.Op_Semi _>
                                )
                              ]
                            )
                          action: [
                            (C {<echo>} {(DQ <Quitting>)})
                            (command.ControlFlow
                              token: <Id.ControlFlow_Exit exit>
                              arg_word: {<0>}
                            )
                          ]
                          spids: [543 561]
                        )
                        (if_arm
                          cond: 
                            (condition.Shell
                              commands: [
                                (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: <Id.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]
                        )
                      ]
                    )
                  ]
                )
            )
          ]
        )
    )
    (command.ShFunction
      name: cleanup
      body: 
        (BraceGroup
          children: [
            (C {<rm>} {<-rf>} {($ Id.VSub_DollarName '$WORKING_DIR')})
            (C {<pkill>} {<-9>} {<jekyll>})
          ]
        )
    )
    (C {<trap>} {<cleanup>} {<EXIT>})
    (C {<main>})
  ]
)