(CommandList
  children: [
    (AndOr
      children: [
        (FuncDef
          name: _pkgadd
          body: 
            (BraceGroup
              children: [
                (Assignment
                  keyword: Assign_Local
                  pairs: [
                    (assign_pair lhs:(LhsName name:cur) op:Equal spids:[20])
                    (assign_pair lhs:(LhsName name:prev) op:Equal spids:[22])
                    (assign_pair lhs:(LhsName name:words) op:Equal spids:[24])
                    (assign_pair lhs:(LhsName name:cword) op:Equal spids:[26])
                  ]
                  spids: [18]
                )
                (AndOr
                  children: [
                    (C {(_init_completion)} {(-n)} {(Lit_Other ':')})
                    (ControlFlow token:<ControlFlow_Return return>)
                  ]
                  op_id: Op_DPipe
                )
                (Sentence
                  child: 
                    (Assignment
                      keyword: Assign_Local
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:device)
                          op: Equal
                          rhs: {(/var/spool/pkg)}
                          spids: [55]
                        )
                      ]
                      spids: [53]
                    )
                  terminator: <Op_Semi ';'>
                )
                (Assignment
                  keyword: Assign_Local
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:i)
                      op: Equal
                      rhs: {($ VSub_Name '$cword')}
                      spids: [62]
                    )
                  ]
                  spids: [60]
                )
                (Sentence
                  child: 
                    (While
                      cond: [
                        (Sentence
                          child: 
                            (DBracket
                              expr: 
                                (BoolBinary
                                  op_id: BoolBinary_gt
                                  left: 
                                    {
                                      (ArithSubPart
                                        anode: 
                                          (UnaryAssign
                                            op_id: Node_PostDMinus
                                            child: (LhsName name:i)
                                          )
                                        spids: [70 74]
                                      )
                                    }
                                  right: {(0)}
                                )
                            )
                          terminator: <Op_Semi ';'>
                        )
                      ]
                      body: 
                        (DoGroup
                          children: [
                            (Sentence
                              child: 
                                (Case
                                  to_match: 
                                    {
                                      (DQ 
                                        (BracedVarSub
                                          token: <VSub_Name words>
                                          bracket_op: 
                                            (ArrayIndex
                                              expr: (ArithWord w:{($ VSub_Name '$i')})
                                            )
                                          spids: [89 94]
                                        )
                                      )
                                    }
                                  arms: [
                                    (case_arm
                                      pat_list: [{(-d)}]
                                      action: [
                                        (Sentence
                                          child: 
                                            (Assignment
                                              keyword: Assign_None
                                              pairs: [
                                                (assign_pair
                                                  lhs: (LhsName name:device)
                                                  op: Equal
                                                  rhs: 
                                                    {
                                                      (DQ 
                                                        (BracedVarSub
                                                          token: <VSub_Name words>
                                                          bracket_op: 
                                                            (ArrayIndex
                                                              expr: 
                                                                (ArithWord
                                                                  w: 
                                                                    {
                                                                      (ArithSubPart
                                                                        anode: 
                                                                          (ArithBinary
                                                                            op_id: Arith_Plus
                                                                            left: 
                                                                              (ArithVarRef
                                                                                name: i
                                                                              )
                                                                            right: 
                                                                              (ArithWord
                                                                                w: {(Lit_Digits 1)}
                                                                              )
                                                                          )
                                                                        spids: [109 114]
                                                                      )
                                                                    }
                                                                )
                                                            )
                                                          spids: [106 116]
                                                        )
                                                      )
                                                    }
                                                  spids: [104]
                                                )
                                              ]
                                              spids: [104]
                                            )
                                          terminator: <Op_Semi ';'>
                                        )
                                        (ControlFlow
                                          token: <ControlFlow_Break break>
                                        )
                                      ]
                                      spids: [100 101 124 16777215]
                                    )
                                  ]
                                  spids: [86 97 127]
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          spids: [83 131]
                        )
                    )
                  terminator: <Op_Semi ';'>
                )
                (Case
                  to_match: {($ VSub_Name '$prev')}
                  arms: [
                    (case_arm
                      pat_list: [{(-d)}]
                      action: [(C {(_filedir)} {(pkg)}) (C {(_filedir)} {(-d)})]
                      spids: [144 145 158 16777215]
                    )
                    (case_arm
                      pat_list: [{(-a)} {(-r)} {(-V)}]
                      action: [(C {(_filedir)})]
                      spids: [161 166 172 16777215]
                    )
                    (case_arm
                      pat_list: [{(-k)} {(-s)} {(-R)}]
                      action: [(C {(_filedir)} {(-d)})]
                      spids: [175 180 188 16777215]
                    )
                    (case_arm
                      pat_list: [{(-P)} {(-k)} {(-x)}]
                      spids: [191 196 199 16777215]
                    )
                    (case_arm
                      pat_list: [{(Lit_Other '*')}]
                      action: [
                        (If
                          arms: [
                            (if_arm
                              cond: [
                                (Sentence
                                  child: 
                                    (DBracket
                                      expr: 
                                        (BoolBinary
                                          op_id: BoolBinary_GlobDEqual
                                          left: {(${ VSub_Name cur)}
                                          right: {(-) (Lit_Other '*')}
                                        )
                                    )
                                  terminator: <Op_Semi ';'>
                                )
                              ]
                              action: [
                                (Assignment
                                  keyword: Assign_Local
                                  pairs: [
                                    (assign_pair
                                      lhs: (LhsName name:opts)
                                      op: Equal
                                      rhs: {(DQ ('-a -A -d -k -n -M -P -r -R -s -v -V -x'))}
                                      spids: [228]
                                    )
                                  ]
                                  spids: [226]
                                )
                                (Assignment
                                  keyword: Assign_None
                                  pairs: [
                                    (assign_pair
                                      lhs: (LhsName name:COMPREPLY)
                                      op: Equal
                                      rhs: 
                                        {
                                          (ArrayLiteralPart
                                            words: [
                                              {
                                                (CommandSubPart
                                                  command_list: 
                                                    (CommandList
                                                      children: [
                                                        (C {(compgen)} {(-W)} {(DQ (${ VSub_Name opts))} 
                                                          {(--)} {(${ VSub_Name cur)}
                                                        )
                                                      ]
                                                    )
                                                  left_token: <Left_CommandSub '$('>
                                                  spids: [237 253]
                                                )
                                              }
                                            ]
                                          )
                                        }
                                      spids: [234]
                                    )
                                  ]
                                  spids: [234]
                                )
                              ]
                              spids: [16777215 223]
                            )
                          ]
                          else_action: [
                            (Assignment
                              keyword: Assign_Local
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:pkginst_list)
                                  op: Equal
                                  spids: [263]
                                )
                              ]
                              spids: [261]
                            )
                            (If
                              arms: [
                                (if_arm
                                  cond: [
                                    (Sentence
                                      child: 
                                        (DBracket
                                          expr: 
                                            (BoolUnary
                                              op_id: BoolUnary_d
                                              child: {($ VSub_Name '$device')}
                                            )
                                        )
                                      terminator: <Op_Semi ';'>
                                    )
                                  ]
                                  action: [
                                    (ForEach
                                      iter_name: filedir
                                      iter_words: [
                                        {
                                          (CommandSubPart
                                            command_list: 
                                              (CommandList
                                                children: [
                                                  (C {(/bin/ls)} {(-1)} {($ VSub_Name '$device')})
                                                ]
                                              )
                                            left_token: <Left_CommandSub '$('>
                                            spids: [286 292]
                                          )
                                        }
                                      ]
                                      do_arg_iter: False
                                      body: 
                                        (DoGroup
                                          children: [
                                            (If
                                              arms: [
                                                (if_arm
                                                  cond: [
                                                    (Sentence
                                                      child: 
                                                        (AndOr
                                                          children: [
                                                            (DBracket
                                                              expr: 
                                                                (BoolUnary
                                                                  op_id: BoolUnary_d
                                                                  child: 
                                                                    {
                                                                      (DQ ($ VSub_Name '$device') (/) 
                                                                        ($ VSub_Name '$filedir')
                                                                      )
                                                                    }
                                                                )
                                                            )
                                                            (DBracket
                                                              expr: 
                                                                (BoolUnary
                                                                  op_id: BoolUnary_f
                                                                  child: 
                                                                    {
                                                                      (DQ ($ VSub_Name '$device') (/) 
                                                                        ($ VSub_Name '$filedir') (/pkginfo)
                                                                      )
                                                                    }
                                                                )
                                                            )
                                                          ]
                                                          op_id: Op_DAmp
                                                        )
                                                      terminator: <Op_Semi ';'>
                                                    )
                                                  ]
                                                  action: [
                                                    (Assignment
                                                      keyword: Assign_None
                                                      pairs: [
                                                        (assign_pair
                                                          lhs: (LhsName name:pkginst_list)
                                                          op: PlusEqual
                                                          rhs: 
                                                            {
                                                              (ArrayLiteralPart
                                                                words: [
                                                                  {
                                                                    (BracedVarSub
                                                                      token: <VSub_Name pkginst_list>
                                                                      bracket_op: 
                                                                        (WholeArray
                                                                          op_id: Lit_At
                                                                        )
                                                                      suffix_op: 
                                                                        (StringUnary
                                                                          op_id: VTest_ColonHyphen
                                                                          arg_word: {}
                                                                        )
                                                                      spids: [334 340]
                                                                    )
                                                                  }
                                                                  {(DQ ($ VSub_Name '$filedir'))}
                                                                ]
                                                              )
                                                            }
                                                          spids: [331]
                                                        )
                                                      ]
                                                      spids: [331]
                                                    )
                                                  ]
                                                  spids: [16777215 328]
                                                )
                                              ]
                                              spids: [16777215 349]
                                            )
                                          ]
                                          spids: [295 352]
                                        )
                                      spids: [285 293]
                                    )
                                    (Assignment
                                      keyword: Assign_None
                                      pairs: [
                                        (assign_pair
                                          lhs: (LhsName name:pkginst_list)
                                          op: Equal
                                          rhs: 
                                            {
                                              (DQ 
                                                (BracedVarSub
                                                  token: <VSub_Name pkginst_list>
                                                  bracket_op: (WholeArray op_id:Lit_At)
                                                  spids: [357 362]
                                                )
                                              )
                                            }
                                          spids: [355]
                                        )
                                      ]
                                      spids: [355]
                                    )
                                  ]
                                  spids: [16777215 277]
                                )
                              ]
                              else_action: [
                                (Assignment
                                  keyword: Assign_None
                                  pairs: [
                                    (assign_pair
                                      lhs: (LhsName name:pkginst_list)
                                      op: Equal
                                      rhs: 
                                        {
                                          (CommandSubPart
                                            command_list: 
                                              (CommandList
                                                children: [
                                                  (Pipeline
                                                    children: [
                                                      (C {(strings)} 
                                                        {
                                                          (CommandSubPart
                                                            command_list: 
                                                              (CommandList
                                                                children: [
                                                                  (C {(dequote)} 
                                                                    {($ VSub_Name '$device')}
                                                                  )
                                                                ]
                                                              )
                                                            left_token: <Left_CommandSub '$('>
                                                            spids: [373 377]
                                                          )
                                                        }
                                                      )
                                                      (C {(command)} {(grep)} {(DQ ('^PKG='))})
                                                      (C {(sort)} {(-u)})
                                                      (C {(cut)} {(-d) (Lit_Other '=')} {(-f2)})
                                                    ]
                                                    negated: False
                                                  )
                                                ]
                                              )
                                            left_token: <Left_CommandSub '$('>
                                            spids: [370 405]
                                          )
                                        }
                                      spids: [369]
                                    )
                                  ]
                                  spids: [369]
                                )
                              ]
                              spids: [366 408]
                            )
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:COMPREPLY)
                                  op: Equal
                                  rhs: 
                                    {
                                      (ArrayLiteralPart
                                        words: [
                                          {
                                            (CommandSubPart
                                              command_list: 
                                                (CommandList
                                                  children: [
                                                    (C {(compgen)} {(-W)} 
                                                      {(DQ ($ VSub_Name '$pkginst_list'))} {(--)} {(${ VSub_Name cur)}
                                                    )
                                                  ]
                                                )
                                              left_token: <Left_CommandSub '$('>
                                              spids: [414 428]
                                            )
                                          }
                                        ]
                                      )
                                    }
                                  spids: [411]
                                )
                              ]
                              spids: [411]
                            )
                          ]
                          spids: [258 433]
                        )
                      ]
                      spids: [202 203 16777215 436]
                    )
                  ]
                  spids: [136 140 436]
                )
              ]
              spids: [15]
            )
          spids: [10 14]
        )
        (C {(complete)} {(-F)} {(_pkgadd)} {(pkgadd)})
      ]
      op_id: Op_DAmp
    )
  ]
)