(command.CommandList
  children: [
    (command.ShFunction
      name: err_exit
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (C {<print>} {<-u2>} {<-n>} {(DQ <Id.Lit_BadBackslash '\\'> <t>)})
            (C {<print>} {<-u2>} {<-r>} 
              {(${ Id.VSub_Name Command) <Id.Lit_LBracket '['> ($ Id.VSub_Number 1) 
                <Id.Lit_RBracket ']'> <Id.Lit_Colon ':'>
              } 
              {
                (DQ 
                  (braced_var_sub
                    left: <Id.Left_DollarBrace '${'>
                    token: <Id.VSub_At '@'>
                    var_name: '@'
                    suffix_op: (suffix_op.Slice begin:{<Id.Lit_Digits 2>})
                    right: <Id.Arith_RBrace _>
                  )
                )
              }
            )
            (C {<let>} {<Id.Lit_VarLike 'Errors+='> <1>})
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (C {<alias>} {<Id.Lit_VarLike 'err_exit='> (SQ <'err_exit $LINENO'>)})
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'Command='> name:Command)
          op: assign_op.Equal
          rhs: 
            {
              (braced_var_sub
                left: <Id.Left_DollarBrace '${'>
                token: <Id.VSub_Number 0>
                var_name: 0
                suffix_op: 
                  (suffix_op.Unary
                    op: <Id.VOp1_DPound '##'>
                    arg_word: {<Id.Lit_Other '*'> <Id.Lit_Slash '/'>}
                  )
                right: <Id.Right_DollarBrace '}'>
              )
            }
          spids: [114]
        )
      ]
      redirects: []
    )
    (C {<integer>} {<Id.Lit_VarLike 'Errors='> <0>})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'tmp='> name:tmp)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: <Id.Left_DollarParen '$('>
                    child: (C {<mktemp>} {<-dt>})
                    right: <Id.Eof_RParen _>
                  )
                }
              spids: [128]
            )
          ]
          redirects: []
        )
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.Sentence
              child: (C {<err_exit>} {<mktemp>} {<-dt>} {<failed>})
              terminator: <Id.Op_Semi _>
            )
            (command.Sentence
              child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
              terminator: <Id.Op_Semi _>
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
      ]
    )
    (C {<trap>} {(DQ <'cd /; rm -rf '> ($ Id.VSub_DollarName tmp))} {<EXIT>})
    (command.ShFunction
      name: grep
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'vflag='> name:vflag)
                  op: assign_op.Equal
                  rhs: (rhs_word.Empty)
                  spids: [184]
                )
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'xflag='> name:xflag)
                  op: assign_op.Equal
                  rhs: (rhs_word.Empty)
                  spids: [186]
                )
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'cflag='> name:cflag)
                  op: assign_op.Equal
                  rhs: (rhs_word.Empty)
                  spids: [188]
                )
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'lflag='> name:lflag)
                  op: assign_op.Equal
                  rhs: (rhs_word.Empty)
                  spids: [190]
                )
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'nflag='> name:nflag)
                  op: assign_op.Equal
                  rhs: (rhs_word.Empty)
                  spids: [192]
                )
              ]
              redirects: []
            )
            (C {<set>} {<-f>})
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: 
                (condition.Shell
                  commands: [(command.DParen child:{<Id.Lit_Digits 1>} redirects:[])]
                )
              body: 
                (command.DoGroup
                  children: [
                    (command.Case
                      to_match: {(DQ ($ Id.VSub_Number 1))}
                      arms: [
                        (case_arm
                          pat_list: [{<-v> <Id.Lit_Star '*'>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'vflag='> name:vflag)
                                  op: assign_op.Equal
                                  rhs: {<1>}
                                  spids: [226]
                                )
                              ]
                              redirects: []
                            )
                          ]
                          spids: [222 224 228 -1]
                        )
                        (case_arm
                          pat_list: [{<-x> <Id.Lit_Star '*'>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'xflag='> name:xflag)
                                  op: assign_op.Equal
                                  rhs: {<1>}
                                  spids: [235]
                                )
                              ]
                              redirects: []
                            )
                          ]
                          spids: [231 233 237 -1]
                        )
                        (case_arm
                          pat_list: [{<-c> <Id.Lit_Star '*'>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'cflag='> name:cflag)
                                  op: assign_op.Equal
                                  rhs: {<1>}
                                  spids: [244]
                                )
                              ]
                              redirects: []
                            )
                          ]
                          spids: [240 242 246 -1]
                        )
                        (case_arm
                          pat_list: [{<-l> <Id.Lit_Star '*'>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'lflag='> name:lflag)
                                  op: assign_op.Equal
                                  rhs: {<1>}
                                  spids: [253]
                                )
                              ]
                              redirects: []
                            )
                          ]
                          spids: [249 251 255 -1]
                        )
                        (case_arm
                          pat_list: [{<-n> <Id.Lit_Star '*'>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'nflag='> name:nflag)
                                  op: assign_op.Equal
                                  rhs: {<1>}
                                  spids: [262]
                                )
                              ]
                              redirects: []
                            )
                          ]
                          spids: [258 260 264 -1]
                        )
                        (case_arm
                          pat_list: [{<-b> <Id.Lit_Star '*'>}]
                          action: [(C {<print>} {(SQ <'b option not supported'>)})]
                          spids: [267 269 276 -1]
                        )
                        (case_arm
                          pat_list: [{<-e> <Id.Lit_Star '*'>}]
                          action: [
                            (command.Sentence
                              child: (C {<shift>})
                              terminator: <Id.Op_Semi _>
                            )
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'expr='> name:expr)
                                  op: assign_op.Equal
                                  rhs: {(DQ ($ Id.VSub_Number 1))}
                                  spids: [285]
                                )
                              ]
                              redirects: []
                            )
                          ]
                          spids: [279 281 289 -1]
                        )
                        (case_arm
                          pat_list: [{<-f> <Id.Lit_Star '*'>}]
                          action: [
                            (command.Sentence
                              child: (C {<shift>})
                              terminator: <Id.Op_Semi _>
                            )
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'expr='> name:expr)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (command_sub
                                        left_token: <Id.Left_DollarParen '$('>
                                        child: 
                                          (command.Simple
                                            words: []
                                            redirects: [
                                              (redir
                                                op: <Id.Redir_Less '<'>
                                                loc: (redir_loc.Fd fd:0)
                                                arg: {($ Id.VSub_Number 1)}
                                              )
                                            ]
                                            more_env: []
                                            do_fork: F
                                          )
                                        right: <Id.Eof_RParen _>
                                      )
                                    }
                                  spids: [298]
                                )
                              ]
                              redirects: []
                            )
                          ]
                          spids: [292 294 304 -1]
                        )
                        (case_arm
                          pat_list: [{<-> <Id.Lit_Star '*'>}]
                          action: [
                            (command.Sentence
                              child: 
                                (C {<print>} {($ Id.VSub_Number 0) <Id.Lit_Colon ':'>} 
                                  {(SQ <'unknown flag'>)}
                                )
                              terminator: <Id.Op_Semi _>
                            )
                            (command.ControlFlow
                              token: <Id.ControlFlow_Return return>
                              arg_word: {<2>}
                            )
                          ]
                          spids: [307 309 323 -1]
                        )
                        (case_arm
                          pat_list: [{<Id.Lit_Star '*'>}]
                          action: [
                            (command.If
                              arms: [
                                (if_arm
                                  cond: 
                                    (condition.Shell
                                      commands: [
                                        (C {<test>} {(DQ ($ Id.VSub_DollarName expr))} 
                                          {<Id.Lit_Equals '='>} {(SQ )}
                                        )
                                      ]
                                    )
                                  action: [
                                    (command.Sentence
                                      child: 
                                        (command.ShAssignment
                                          pairs: [
                                            (assign_pair
                                              lhs: 
                                                (sh_lhs_expr.Name
                                                  left: <Id.Lit_VarLike 'expr='>
                                                  name: expr
                                                )
                                              op: assign_op.Equal
                                              rhs: {(DQ ($ Id.VSub_Number 1))}
                                              spids: [346]
                                            )
                                          ]
                                          redirects: []
                                        )
                                      terminator: <Id.Op_Semi _>
                                    )
                                    (C {<shift>})
                                  ]
                                  spids: [330 344]
                                )
                              ]
                              else_action: []
                              redirects: []
                            )
                            (command.AndOr
                              ops: [Id.Op_DPipe]
                              children: [
                                (C {<test>} {(DQ ($ Id.VSub_DollarName xflag))})
                                (command.ShAssignment
                                  pairs: [
                                    (assign_pair
                                      lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'expr='> name:expr)
                                      op: assign_op.Equal
                                      rhs: {(DQ <'*'> (${ Id.VSub_Name expr) <'*'>)}
                                      spids: [365]
                                    )
                                  ]
                                  redirects: []
                                )
                              ]
                            )
                            (command.ControlFlow
                              token: <Id.ControlFlow_Break break>
                            )
                          ]
                          spids: [326 327 376 -1]
                        )
                      ]
                      redirects: []
                    )
                    (C {<shift>})
                  ]
                )
              redirects: []
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'noprint='> name:noprint)
                  op: assign_op.Equal
                  rhs: 
                    {($ Id.VSub_DollarName vflag) ($ Id.VSub_DollarName cflag) 
                      ($ Id.VSub_DollarName lflag)
                    }
                  spids: [391]
                )
              ]
              redirects: []
            )
            (C {<integer>} {<Id.Lit_VarLike 'n='> <0>} {<Id.Lit_VarLike 'c='> <0>} 
              {<Id.Lit_VarLike 'tc='> <0>} {<Id.Lit_VarLike 'nargs='> ($ Id.VSub_Pound '#')}
            )
            (command.ForEach
              iter_names: [i]
              iterable: (for_iter.Words words:[{(DQ ($ Id.VSub_At '@'))}])
              body: 
                (command.DoGroup
                  children: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: 
                            (condition.Shell
                              commands: [
                                (command.DParen
                                  child: 
                                    (arith_expr.Binary
                                      op_id: Id.Arith_LessEqual
                                      left: ($ Id.Lit_ArithVarLike nargs)
                                      right: {<Id.Lit_Digits 1>}
                                    )
                                  redirects: []
                                )
                              ]
                            )
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'fname='> name:fname)
                                  op: assign_op.Equal
                                  rhs: {(SQ )}
                                  spids: [446]
                                )
                              ]
                              redirects: []
                            )
                          ]
                          spids: [434 444]
                        )
                      ]
                      else_action: [
                        (command.ShAssignment
                          pairs: [
                            (assign_pair
                              lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'fname='> name:fname)
                              op: assign_op.Equal
                              rhs: {(DQ ($ Id.VSub_DollarName i)) <Id.Lit_Colon ':'>}
                              spids: [453]
                            )
                          ]
                          redirects: []
                        )
                      ]
                      redirects: []
                    )
                    (command.AndOr
                      ops: [Id.Op_DAmp]
                      children: [
                        (C {<test>} {(DQ ($ Id.VSub_DollarName i))})
                        (command.Simple
                          words: [{<exec>}]
                          redirects: [
                            (redir
                              op: <Id.Redir_Less '0<'>
                              loc: (redir_loc.Fd fd:0)
                              arg: {($ Id.VSub_DollarName i)}
                            )
                          ]
                          more_env: []
                          do_fork: T
                        )
                      ]
                    )
                    (command.WhileUntil
                      keyword: <Id.KW_While while>
                      cond: (condition.Shell commands:[(C {<read>} {<-r>} {<line>})])
                      body: 
                        (command.DoGroup
                          children: [
                            (C {<let>} {<Id.Lit_VarLike 'n='> <n> <Id.Lit_Other '+'> <1>})
                            (command.Case
                              to_match: {(DQ ($ Id.VSub_DollarName line))}
                              arms: [
                                (case_arm
                                  pat_list: [{($ Id.VSub_DollarName expr)}]
                                  action: [
                                    (command.AndOr
                                      ops: [Id.Op_DPipe]
                                      children: [
                                        (C {<test>} {(DQ ($ Id.VSub_DollarName noprint))})
                                        (C {<print>} {<-r>} {<-->} 
                                          {
                                            (DQ ($ Id.VSub_DollarName fname) 
                                              (braced_var_sub
                                                left: <Id.Left_DollarBrace '${'>
                                                token: <Id.VSub_Name nflag>
                                                var_name: nflag
                                                suffix_op: 
                                                  (suffix_op.Unary
                                                    op: <Id.VTest_ColonPlus _>
                                                    arg_word: {($ Id.VSub_DollarName n) <':'>}
                                                  )
                                                right: <Id.Right_DollarBrace '}'>
                                              ) ($ Id.VSub_DollarName line)
                                            )
                                          }
                                        )
                                      ]
                                    )
                                    (C {<let>} {<Id.Lit_VarLike 'c='> <c> <Id.Lit_Other '+'> <1>})
                                  ]
                                  spids: [512 513 552 -1]
                                )
                                (case_arm
                                  pat_list: [{<Id.Lit_Star '*'>}]
                                  action: [
                                    (command.If
                                      arms: [
                                        (if_arm
                                          cond: 
                                            (condition.Shell
                                              commands: [
                                                (C {<test>} {(DQ ($ Id.VSub_DollarName vflag))})
                                              ]
                                            )
                                          action: [
                                            (C {<print>} {<-r>} {<-->} 
                                              {
                                                (DQ ($ Id.VSub_DollarName fname) 
                                                  (braced_var_sub
                                                    left: <Id.Left_DollarBrace '${'>
                                                    token: <Id.VSub_Name nflag>
                                                    var_name: nflag
                                                    suffix_op: 
                                                      (suffix_op.Unary
                                                        op: <Id.VTest_ColonPlus _>
                                                        arg_word: {($ Id.VSub_DollarName n) <':'>}
                                                      )
                                                    right: <Id.Right_DollarBrace '}'>
                                                  ) ($ Id.VSub_DollarName line)
                                                )
                                              }
                                            )
                                          ]
                                          spids: [562 571]
                                        )
                                      ]
                                      else_action: []
                                      redirects: []
                                    )
                                  ]
                                  spids: [555 556 592 -1]
                                )
                              ]
                              redirects: []
                            )
                          ]
                        )
                      redirects: []
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: 
                            (condition.Shell
                              commands: [
                                (command.AndOr
                                  ops: [Id.Op_DAmp]
                                  children: [
                                    (C {<test>} {(DQ ($ Id.VSub_DollarName lflag))})
                                    (command.DParen
                                      child: ($ Id.Lit_ArithVarLike c)
                                      redirects: []
                                    )
                                  ]
                                )
                              ]
                            )
                          action: [(C {<print>} {<-r>} {<-->} {(DQ ($ Id.VSub_DollarName i))})]
                          spids: [601 617]
                        )
                      ]
                      else_action: []
                      redirects: []
                    )
                    (C {<let>} {<Id.Lit_VarLike 'tc='> <tc> <Id.Lit_Other '+'> <c>} 
                      {<Id.Lit_VarLike 'n='> <0>} {<Id.Lit_VarLike 'c='> <0>}
                    )
                  ]
                )
              redirects: []
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (C {<test>} {(DQ ($ Id.VSub_DollarName cflag))})
                (C {<print>} {($ Id.VSub_DollarName tc)})
              ]
            )
            (C {<let>} {<tc>})
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir
          op: <Id.Redir_Great '>'>
          loc: (redir_loc.Fd fd:1)
          arg: {($ Id.VSub_DollarName tmp) <'/grep'>}
        )
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\!'> ch:'!')}
              here_end_span_id: 694
              stdin_parts: [
                <'this is a food bar test\n'>
                <'to see how many lines find both foo and bar.\n'>
                <'Some line contain foo only,\n'>
                <'and some lines contain bar only.\n'>
                <'However, many lines contain both foo and also bar.\n'>
                <'A line containing foobar should also be counted.\n'>
                <'There should be six lines with foo and bar.\n'>
                <'There are only two line with out foo but with bar.\n'>
              ]
            )
        )
      ]
      more_env: []
      do_fork: T
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.DParen
                  child: 
                    (arith_expr.Binary
                      op_id: Id.Arith_NEqual
                      left: 
                        {
                          (command_sub
                            left_token: <Id.Left_DollarParen '$('>
                            child: 
                              (C {<grep>} {<-c>} {(SQ <'foo*bar'>)} 
                                {($ Id.VSub_DollarName tmp) <'/grep'>}
                              )
                            right: <Id.Eof_RParen _>
                          )
                        }
                      right: {<Id.Lit_Digits 6>}
                    )
                  redirects: []
                )
              ]
            )
          action: [(C {<err_exit>})]
          spids: [696 720]
        )
      ]
      else_action: []
      redirects: []
    )
    (command.ControlFlow
      token: <Id.ControlFlow_Exit exit>
      arg_word: {(word_part.ArithSub anode:($ Id.Lit_ArithVarLike Errors))}
    )
  ]
)