(CommandList
  children: [
    (FuncDef
      name: err_exit
      body: 
        (BraceGroup
          children: [
            (C {(print)} {(-u2)} {(-n)} {(DQ (EscapedLiteralPart token:<Lit_EscapedChar "\\t">))})
            (C {(print)} {(-u2)} {(-r)} 
              {(${ VSub_Name Command) (Lit_Other "[") ($ VSub_Number "$1") (Lit_Other "]") 
                (Lit_Other ":")
              } 
              {
                (DQ 
                  (BracedVarSub
                    token: <VSub_At "@">
                    suffix_op: (Slice begin:(ArithWord w:{(Lit_Digits 2)}))
                    spids: [90 94]
                  )
                )
              }
            )
            (C {(let)} {(Lit_VarLike "Errors+=") (1)})
          ]
          spids: [61]
        )
      spids: [57 60]
    )
    (C {(alias)} {(Lit_VarLike "err_exit=") (SQ <"err_exit $LINENO">)})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:Command)
          op: Equal
          rhs: 
            {
              (BracedVarSub
                token: <VSub_Number 0>
                suffix_op: (StringUnary op_id:VOp1_DPound arg_word:{("*") (Lit_Slash /)})
                spids: [114 119]
              )
            }
          spids: [113]
        )
      ]
      spids: [113]
    )
    (C {(integer)} {(Lit_VarLike "Errors=") (0)})
    (AndOr
      children: [
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:tmp)
              op: Equal
              rhs: 
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(mktemp)} {(-dt)})])
                    left_token: <Left_CommandSub "$(">
                    spids: [128 132]
                  )
                }
              spids: [127]
            )
          ]
          spids: [127]
        )
        (BraceGroup
          children: [
            (Sentence
              child: (C {(err_exit)} {(mktemp)} {(-dt)} {(failed)})
              terminator: <Op_Semi ";">
            )
            (Sentence child:(C {(exit)} {(1)}) terminator:<Op_Semi ";">)
          ]
          spids: [136]
        )
      ]
      op_id: Op_DPipe
    )
    (C {(trap)} {(DQ ("cd /; rm -rf ") ($ VSub_Name "$tmp"))} {(EXIT)})
    (FuncDef
      name: grep
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:vflag)
                  op: Equal
                  rhs: {(SQ )}
                  spids: [183]
                )
                (assign_pair
                  lhs: (LhsName name:xflag)
                  op: Equal
                  rhs: {(SQ )}
                  spids: [185]
                )
                (assign_pair
                  lhs: (LhsName name:cflag)
                  op: Equal
                  rhs: {(SQ )}
                  spids: [187]
                )
                (assign_pair
                  lhs: (LhsName name:lflag)
                  op: Equal
                  rhs: {(SQ )}
                  spids: [189]
                )
                (assign_pair
                  lhs: (LhsName name:nflag)
                  op: Equal
                  rhs: {(SQ )}
                  spids: [191]
                )
              ]
              spids: [183]
            )
            (C {(set)} {(-f)})
            (While
              cond: [(DParen child:(ArithWord w:{(Lit_Digits 1)}))]
              body: 
                (DoGroup
                  children: [
                    (Case
                      to_match: {(DQ ($ VSub_Number "$1"))}
                      arms: [
                        (case_arm
                          pat_list: [{(-v) (Lit_Other "*")}]
                          action: [
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:vflag)
                                  op: Equal
                                  rhs: {(1)}
                                  spids: [225]
                                )
                              ]
                              spids: [225]
                            )
                          ]
                          spids: [221 223 227 -1]
                        )
                        (case_arm
                          pat_list: [{(-x) (Lit_Other "*")}]
                          action: [
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:xflag)
                                  op: Equal
                                  rhs: {(1)}
                                  spids: [234]
                                )
                              ]
                              spids: [234]
                            )
                          ]
                          spids: [230 232 236 -1]
                        )
                        (case_arm
                          pat_list: [{(-c) (Lit_Other "*")}]
                          action: [
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:cflag)
                                  op: Equal
                                  rhs: {(1)}
                                  spids: [243]
                                )
                              ]
                              spids: [243]
                            )
                          ]
                          spids: [239 241 245 -1]
                        )
                        (case_arm
                          pat_list: [{(-l) (Lit_Other "*")}]
                          action: [
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:lflag)
                                  op: Equal
                                  rhs: {(1)}
                                  spids: [252]
                                )
                              ]
                              spids: [252]
                            )
                          ]
                          spids: [248 250 254 -1]
                        )
                        (case_arm
                          pat_list: [{(-n) (Lit_Other "*")}]
                          action: [
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:nflag)
                                  op: Equal
                                  rhs: {(1)}
                                  spids: [261]
                                )
                              ]
                              spids: [261]
                            )
                          ]
                          spids: [257 259 263 -1]
                        )
                        (case_arm
                          pat_list: [{(-b) (Lit_Other "*")}]
                          action: [(C {(print)} {(SQ <"b option not supported">)})]
                          spids: [266 268 275 -1]
                        )
                        (case_arm
                          pat_list: [{(-e) (Lit_Other "*")}]
                          action: [
                            (Sentence
                              child: (C {(shift)})
                              terminator: <Op_Semi ";">
                            )
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:expr)
                                  op: Equal
                                  rhs: {(DQ ($ VSub_Number "$1"))}
                                  spids: [284]
                                )
                              ]
                              spids: [284]
                            )
                          ]
                          spids: [278 280 288 -1]
                        )
                        (case_arm
                          pat_list: [{(-f) (Lit_Other "*")}]
                          action: [
                            (Sentence
                              child: (C {(shift)})
                              terminator: <Op_Semi ";">
                            )
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:expr)
                                  op: Equal
                                  rhs: 
                                    {
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [
                                              (SimpleCommand
                                                redirects: [
                                                  (Redir
                                                    op_id: Redir_Less
                                                    fd: -1
                                                    arg_word: {($ VSub_Number "$1")}
                                                    spids: [299]
                                                  )
                                                ]
                                              )
                                            ]
                                          )
                                        left_token: <Left_CommandSub "$(">
                                        spids: [298 302]
                                      )
                                    }
                                  spids: [297]
                                )
                              ]
                              spids: [297]
                            )
                          ]
                          spids: [291 293 303 -1]
                        )
                        (case_arm
                          pat_list: [{(-) (Lit_Other "*")}]
                          action: [
                            (Sentence
                              child: 
                                (C {(print)} {($ VSub_Number "$0") (Lit_Other ":")} 
                                  {(SQ <"unknown flag">)}
                                )
                              terminator: <Op_Semi ";">
                            )
                            (ControlFlow
                              token: <ControlFlow_Return return>
                              arg_word: {(2)}
                            )
                          ]
                          spids: [306 308 322 -1]
                        )
                        (case_arm
                          pat_list: [{(Lit_Other "*")}]
                          action: [
                            (If
                              arms: [
                                (if_arm
                                  cond: [(C {(test)} {(DQ ($ VSub_Name "$expr"))} {(Lit_Other "=")} {(SQ )})]
                                  action: [
                                    (Sentence
                                      child: 
                                        (Assignment
                                          keyword: Assign_None
                                          pairs: [
                                            (assign_pair
                                              lhs: (LhsName name:expr)
                                              op: Equal
                                              rhs: {(DQ ($ VSub_Number "$1"))}
                                              spids: [345]
                                            )
                                          ]
                                          spids: [345]
                                        )
                                      terminator: <Op_Semi ";">
                                    )
                                    (C {(shift)})
                                  ]
                                  spids: [-1 343]
                                )
                              ]
                              spids: [-1 353]
                            )
                            (AndOr
                              children: [
                                (C {(test)} {(DQ ($ VSub_Name "$xflag"))})
                                (Assignment
                                  keyword: Assign_None
                                  pairs: [
                                    (assign_pair
                                      lhs: (LhsName name:expr)
                                      op: Equal
                                      rhs: {(DQ ("*") (${ VSub_Name expr) ("*"))}
                                      spids: [364]
                                    )
                                  ]
                                  spids: [364]
                                )
                              ]
                              op_id: Op_DPipe
                            )
                            (ControlFlow token:<ControlFlow_Break break>)
                          ]
                          spids: [325 326 375 -1]
                        )
                      ]
                      spids: [212 218 378]
                    )
                    (C {(shift)})
                  ]
                  spids: [210 387]
                )
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:noprint)
                  op: Equal
                  rhs: {($ VSub_Name "$vflag") ($ VSub_Name "$cflag") ($ VSub_Name "$lflag")}
                  spids: [390]
                )
              ]
              spids: [390]
            )
            (C {(integer)} {(Lit_VarLike "n=") (0)} {(Lit_VarLike "c=") (0)} {(Lit_VarLike "tc=") (0)} 
              {(Lit_VarLike "nargs=") ($ VSub_Pound "$#")}
            )
            (ForEach
              iter_name: i
              iter_words: [{(DQ ($ VSub_At "$@"))}]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (DParen
                              child: 
                                (ArithBinary
                                  op_id: Arith_LessEqual
                                  left: (ArithVarRef name:nargs)
                                  right: (ArithWord w:{(Lit_Digits 1)})
                                )
                            )
                          ]
                          action: [
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:fname)
                                  op: Equal
                                  rhs: {(SQ )}
                                  spids: [445]
                                )
                              ]
                              spids: [445]
                            )
                          ]
                          spids: [-1 443]
                        )
                      ]
                      else_action: [
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:fname)
                              op: Equal
                              rhs: {(DQ ($ VSub_Name "$i")) (Lit_Other ":")}
                              spids: [452]
                            )
                          ]
                          spids: [452]
                        )
                      ]
                      spids: [450 459]
                    )
                    (AndOr
                      children: [
                        (C {(test)} {(DQ ($ VSub_Name "$i"))})
                        (SimpleCommand
                          words: [{(exec)}]
                          redirects: [
                            (Redir
                              op_id: Redir_Less
                              fd: 0
                              arg_word: {($ VSub_Name "$i")}
                              spids: [472]
                            )
                          ]
                        )
                      ]
                      op_id: Op_DAmp
                    )
                    (While
                      cond: [(C {(read)} {(-r)} {(line)})]
                      body: 
                        (DoGroup
                          children: [
                            (C {(let)} {(Lit_VarLike "n=") (n) (Lit_Other "+") (1)})
                            (Case
                              to_match: {(DQ ($ VSub_Name "$line"))}
                              arms: [
                                (case_arm
                                  pat_list: [{($ VSub_Name "$expr")}]
                                  action: [
                                    (AndOr
                                      children: [
                                        (C {(test)} {(DQ ($ VSub_Name "$noprint"))})
                                        (C {(print)} {(-r)} {(--)} 
                                          {
                                            (DQ ($ VSub_Name "$fname") 
                                              (BracedVarSub
                                                token: <VSub_Name nflag>
                                                suffix_op: 
                                                  (StringUnary
                                                    op_id: VTest_ColonPlus
                                                    arg_word: {($ VSub_Name "$n") (":")}
                                                  )
                                                spids: [534 539]
                                              ) ($ VSub_Name "$line")
                                            )
                                          }
                                        )
                                      ]
                                      op_id: Op_DPipe
                                    )
                                    (C {(let)} {(Lit_VarLike "c=") (c) (Lit_Other "+") (1)})
                                  ]
                                  spids: [511 512 551 -1]
                                )
                                (case_arm
                                  pat_list: [{(Lit_Other "*")}]
                                  action: [
                                    (If
                                      arms: [
                                        (if_arm
                                          cond: [(C {(test)} {(DQ ($ VSub_Name "$vflag"))})]
                                          action: [
                                            (C {(print)} {(-r)} {(--)} 
                                              {
                                                (DQ ($ VSub_Name "$fname") 
                                                  (BracedVarSub
                                                    token: <VSub_Name nflag>
                                                    suffix_op: 
                                                      (StringUnary
                                                        op_id: VTest_ColonPlus
                                                        arg_word: {($ VSub_Name "$n") (":")}
                                                      )
                                                    spids: [580 585]
                                                  ) ($ VSub_Name "$line")
                                                )
                                              }
                                            )
                                          ]
                                          spids: [-1 570]
                                        )
                                      ]
                                      spids: [-1 590]
                                    )
                                  ]
                                  spids: [554 555 591 -1]
                                )
                              ]
                              spids: [502 508 594]
                            )
                          ]
                          spids: [492 597]
                        )
                    )
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (AndOr
                              children: [
                                (C {(test)} {(DQ ($ VSub_Name "$lflag"))})
                                (DParen child:(ArithVarRef name:c))
                              ]
                              op_id: Op_DAmp
                            )
                          ]
                          action: [(C {(print)} {(-r)} {(--)} {(DQ ($ VSub_Name "$i"))})]
                          spids: [-1 616]
                        )
                      ]
                      spids: [-1 629]
                    )
                    (C {(let)} {(Lit_VarLike "tc=") (tc) (Lit_Other "+") (c)} {(Lit_VarLike "n=") (0)} 
                      {(Lit_VarLike "c=") (0)}
                    )
                  ]
                  spids: [431 646]
                )
              spids: [422 -1]
            )
            (AndOr
              children: [(C {(test)} {(DQ ($ VSub_Name "$cflag"))}) (C {(print)} {($ VSub_Name "$tc")})]
              op_id: Op_DAmp
            )
            (C {(let)} {(tc)})
          ]
          spids: [168]
        )
      spids: [164 167]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{($ VSub_Name "$tmp") (/grep)} spids:[677])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {("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")
            }
          do_expansion: False
          here_end: "!"
          was_filled: True
          spids: [682]
        )
      ]
    )
    (If
      arms: [
        (if_arm
          cond: [
            (DParen
              child: 
                (ArithBinary
                  op_id: Arith_NEqual
                  left: 
                    (ArithWord
                      w: 
                        {
                          (CommandSubPart
                            command_list: 
                              (CommandList
                                children: [
                                  (C {(grep)} {(-c)} {(SQ <"foo*bar">)} {($ VSub_Name "$tmp") (/grep)})
                                ]
                              )
                            left_token: <Left_CommandSub "$(">
                            spids: [690 702]
                          )
                        }
                    )
                  right: (ArithWord w:{(Lit_Digits 6)})
                )
            )
          ]
          action: [(C {(err_exit)})]
          spids: [-1 710]
        )
      ]
      spids: [-1 714]
    )
    (C {(exit)} 
      {
        (ArithSubPart
          anode: 
            (TernaryOp
              cond: 
                (ArithBinary
                  op_id: Arith_Less
                  left: (ArithVarRef name:Errors)
                  right: (ArithWord w:{(Lit_Digits 125)})
                )
              true_expr: (ArithVarRef name:Errors)
              false_expr: (ArithWord w:{(Lit_Digits 125)})
            )
          spids: [719 728]
        )
      }
    )
  ]
)