(command.AndOr
  ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
  children: [
    (C {<_have>} {<pkg-get>})
    (command.ShFunction
      name: _pkg-get_get_catalog_file
      body: 
        (command.BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'url='> (DQ ($ Id.VSub_Number '$1'))})
            (C {<local>} {<catalog_file>} {<i>} {<conffile>})
            (command.ForEach
              iter_name: file
              iter_words: [
                {</etc/opt/csw/pkg-get.conf>}
                {</opt/csw/etc/pkg-get.conf>}
                {</etc/pkg-get.conf>}
              ]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (command.DBracket
                                  expr: 
                                    (bool_expr.Unary
                                      op_id: Id.BoolUnary_f
                                      child: {($ Id.VSub_DollarName '$file')}
                                    )
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:conffile)
                                  op: assign_op.Equal
                                  rhs: {(DQ ($ Id.VSub_DollarName '$file'))}
                                  spids: [72]
                                )
                              ]
                            )
                            (command.ControlFlow
                              token: <Id.ControlFlow_Break break>
                            )
                          ]
                          spids: [58 69]
                        )
                      ]
                    )
                  ]
                )
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:conffile)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (braced_var_sub
                          token: <Id.VSub_Name conffile>
                          suffix_op: 
                            (suffix_op.Unary
                              op_id: Id.VTest_ColonHyphen
                              arg_word: 
                                {<Id.Lit_Slash /> <opt> <Id.Lit_Slash /> <csw> <Id.Lit_Slash /> <etc> 
                                  <Id.Lit_Slash /> <pkg-get.conf>
                                }
                            )
                        )
                      )
                    }
                  spids: [87]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Unary
                              op_id: Id.BoolUnary_z
                              child: {(DQ ($ Id.VSub_DollarName '$url'))}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:url)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (command_sub
                                left_token: <Id.Left_DollarParen '$('>
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (C {<awk>} {<-F> <Id.Lit_Equals '='>} 
                                        {(SQ <' $1=="url" { print $2 }'>)} {($ Id.VSub_DollarName '$conffile')}
                                      )
                                    ]
                                  )
                              )
                            }
                          spids: [121]
                        )
                      ]
                    )
                  ]
                  spids: [105 118]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:catalog_file)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (braced_var_sub
                          token: <Id.VSub_Name url>
                          suffix_op: 
                            (suffix_op.Unary
                              op_id: Id.VOp1_DPound
                              arg_word: {<'*'> <Id.Lit_Slash /> <Id.Lit_Slash />}
                            )
                        )
                      )
                    }
                  spids: [140]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:catalog_file)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (braced_var_sub
                          token: <Id.VSub_Name catalog_file>
                          suffix_op: 
                            (suffix_op.Unary
                              op_id: Id.VOp1_DPercent
                              arg_word: {<Id.Lit_Slash /> <'*'>}
                            )
                        )
                      )
                    }
                  spids: [152]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:catalog_file)
                  op: assign_op.Equal
                  rhs: {(DQ </var/pkg-get/catalog-> ($ Id.VSub_DollarName '$catalog_file'))}
                  spids: [163]
                )
              ]
            )
            (C {<echo>} {(DQ ($ Id.VSub_DollarName '$catalog_file'))})
          ]
        )
    )
    (command.ShFunction
      name: _pkg-get
      body: 
        (command.BraceGroup
          children: [
            (C {<local>} {<cur>} {<prev>} {<file>} {<catalog_file>} {<url>} {<command>})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:COMPREPLY)
                  op: assign_op.Equal
                  rhs: {(sh_array_literal left:<Id.Op_LParen _>)}
                  spids: [203]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:cur)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (braced_var_sub
                          token: <Id.VSub_Name COMP_WORDS>
                          bracket_op: 
                            (bracket_op.ArrayIndex
                              expr: (arith_expr.VarRef token:<Id.Lit_ArithVarLike COMP_CWORD>)
                            )
                        )
                      )
                    }
                  spids: [208]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:prev)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (braced_var_sub
                          token: <Id.VSub_Name COMP_WORDS>
                          bracket_op: 
                            (bracket_op.ArrayIndex
                              expr: 
                                (arith_expr.Binary
                                  op_id: Id.Arith_Minus
                                  left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike COMP_CWORD>)
                                  right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                                )
                            )
                        )
                      )
                    }
                  spids: [219]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_GlobDEqual
                              left: {(DQ (${ Id.VSub_Name prev))}
                              right: {(DQ <-s>)}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})]
                  spids: [233 252]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:i)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (braced_var_sub
                        token: <Id.VSub_Name COMP_WORDS>
                        prefix_op: (Id.VSub_Pound)
                        bracket_op: (bracket_op.WholeArray op_id:Id.Arith_Star)
                      )
                    }
                  spids: [264]
                )
              ]
            )
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: [
                (command.Sentence
                  child: 
                    (command.DBracket
                      expr: 
                        (bool_expr.Binary
                          op_id: Id.BoolBinary_gt
                          left: {($ Id.VSub_DollarName '$i')}
                          right: {<0>}
                        )
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
              body: 
                (command.DoGroup
                  children: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:i)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (word_part.ArithSub
                                anode: 
                                  (arith_expr.Binary
                                    op_id: Id.Arith_Minus
                                    left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike i>)
                                    right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                                  )
                              )
                            }
                          spids: [291]
                        )
                      ]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (command.DBracket
                                  expr: 
                                    (bool_expr.Binary
                                      op_id: Id.BoolBinary_GlobDEqual
                                      left: 
                                        {
                                          (DQ 
                                            (braced_var_sub
                                              token: <Id.VSub_Name COMP_WORDS>
                                              bracket_op: 
                                                (bracket_op.ArrayIndex
                                                  expr: 
                                                    (arith_expr.ArithWord
                                                      w: {($ Id.VSub_DollarName '$i')}
                                                    )
                                                )
                                            )
                                          )
                                        }
                                      right: {<Id.BoolUnary_s -s>}
                                    )
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:url)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (DQ 
                                        (braced_var_sub
                                          token: <Id.VSub_Name COMP_WORDS>
                                          bracket_op: 
                                            (bracket_op.ArrayIndex
                                              expr: 
                                                (arith_expr.ArithWord
                                                  w: 
                                                    {
                                                      (word_part.ArithSub
                                                        anode: 
                                                          (arith_expr.Binary
                                                            op_id: Id.Arith_Plus
                                                            left: 
                                                              (arith_expr.VarRef
                                                                token: <Id.Lit_ArithVarLike i>
                                                              )
                                                            right: 
                                                              (arith_expr.ArithWord
                                                                w: {<Id.Lit_Digits 1>}
                                                              )
                                                          )
                                                      )
                                                    }
                                                )
                                            )
                                        )
                                      )
                                    }
                                  spids: [323]
                                )
                              ]
                            )
                          ]
                          spids: [300 320]
                        )
                      ]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (command.DBracket
                                  expr: 
                                    (bool_expr.Binary
                                      op_id: Id.BoolBinary_GlobDEqual
                                      left: 
                                        {
                                          (DQ 
                                            (braced_var_sub
                                              token: <Id.VSub_Name COMP_WORDS>
                                              bracket_op: 
                                                (bracket_op.ArrayIndex
                                                  expr: 
                                                    (arith_expr.ArithWord
                                                      w: {($ Id.VSub_DollarName '$i')}
                                                    )
                                                )
                                            )
                                          )
                                        }
                                      right: 
                                        {
                                          (word_part.ExtGlob
                                            op: <Id.ExtGlob_At '@('>
                                            arms: [
                                              {<'-[aDdiUu]'>}
                                              {<available>}
                                              {<describe>}
                                              {<download>}
                                              {<install>}
                                              {<list>}
                                              {<updatecatalog>}
                                              {<upgrade>}
                                            ]
                                          )
                                        }
                                    )
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:command)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (DQ 
                                        (braced_var_sub
                                          token: <Id.VSub_Name COMP_WORDS>
                                          bracket_op: 
                                            (bracket_op.ArrayIndex
                                              expr: 
                                                (arith_expr.ArithWord
                                                  w: {($ Id.VSub_DollarName '$i')}
                                                )
                                            )
                                        )
                                      )
                                    }
                                  spids: [381]
                                )
                              ]
                            )
                          ]
                          spids: [342 378]
                        )
                      ]
                    )
                  ]
                )
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Unary
                              op_id: Id.BoolUnary_n
                              child: {(DQ ($ Id.VSub_DollarName '$command'))}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (command.DBracket
                                  expr: 
                                    (bool_expr.Binary
                                      op_id: Id.BoolBinary_GlobDEqual
                                      left: {(DQ ($ Id.VSub_DollarName '$command'))}
                                      right: 
                                        {
                                          (word_part.ExtGlob
                                            op: <Id.ExtGlob_At '@('>
                                            arms: [{<'-[Ddi]'>} {<describe>} {<download>} {<install>}]
                                          )
                                        }
                                    )
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:catalog_file)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (command_sub
                                        left_token: <Id.Left_DollarParen '$('>
                                        command_list: 
                                          (command.CommandList
                                            children: [
                                              (C {<_pkg-get_get_catalog_file>} 
                                                {(DQ ($ Id.VSub_DollarName '$url'))}
                                              )
                                            ]
                                          )
                                      )
                                    }
                                  spids: [441]
                                )
                              ]
                            )
                            (command.If
                              arms: [
                                (if_arm
                                  cond: [
                                    (command.Sentence
                                      child: 
                                        (command.DBracket
                                          expr: 
                                            (bool_expr.Unary
                                              op_id: Id.BoolUnary_f
                                              child: {($ Id.VSub_DollarName '$catalog_file')}
                                            )
                                        )
                                      terminator: <Id.Op_Semi _>
                                    )
                                  ]
                                  action: [
                                    (C {<local>} 
                                      {<Id.Lit_VarLike 'packages_list='> 
                                        (command_sub
                                          left_token: <Id.Left_DollarParen '$('>
                                          command_list: 
                                            (command.CommandList
                                              children: [
                                                (C {<awk>} 
                                                  {
                                                    (SQ 
                                                      <
' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }'
                                                      >
                                                    )
                                                  } {($ Id.VSub_DollarName '$catalog_file')}
                                                )
                                              ]
                                            )
                                        )
                                      }
                                    )
                                    (command.ShAssignment
                                      pairs: [
                                        (assign_pair
                                          lhs: (sh_lhs_expr.Name name:COMPREPLY)
                                          op: assign_op.Equal
                                          rhs: 
                                            {
                                              (sh_array_literal
                                                left: <Id.Op_LParen _>
                                                words: [
                                                  {
                                                    (command_sub
                                                      left_token: <Id.Left_DollarParen '$('>
                                                      command_list: 
                                                        (command.CommandList
                                                          children: [
                                                            (C {<compgen>} {<-W>} 
                                                              {(DQ (${ Id.VSub_Name packages_list))} {<-->} {(${ Id.VSub_Name cur)}
                                                            )
                                                          ]
                                                        )
                                                    )
                                                  }
                                                ]
                                              )
                                            }
                                          spids: [479]
                                        )
                                      ]
                                    )
                                  ]
                                  spids: [451 462]
                                )
                              ]
                            )
                          ]
                          spids: [415 438]
                        )
                      ]
                    )
                    (command.ControlFlow
                      token: <Id.ControlFlow_Return return>
                      arg_word: {<0>}
                    )
                  ]
                  spids: [399 412]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_GlobDEqual
                              left: {(${ Id.VSub_Name cur)}
                              right: {<-> <Id.Lit_Other '*'>}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (C {<local>} {<Id.Lit_VarLike 'opts='> (DQ <'-c -d -D -f -i -l -s -S -u -U -v'>)})
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:COMPREPLY)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (sh_array_literal
                                left: <Id.Op_LParen _>
                                words: [
                                  {
                                    (command_sub
                                      left_token: <Id.Left_DollarParen '$('>
                                      command_list: 
                                        (command.CommandList
                                          children: [
                                            (C {<compgen>} {<-W>} {(DQ (${ Id.VSub_Name opts))} {<-->} 
                                              {(${ Id.VSub_Name cur)}
                                            )
                                          ]
                                        )
                                    )
                                  }
                                ]
                              )
                            }
                          spids: [546]
                        )
                      ]
                    )
                    (command.ControlFlow
                      token: <Id.ControlFlow_Return return>
                      arg_word: {<0>}
                    )
                  ]
                  spids: [518 535]
                )
              ]
              else_action: [
                (C {<local>} 
                  {<Id.Lit_VarLike 'commands='> 
                    (DQ <'available describe download install list '> 
                      <'            updatecatalog upgrade'>
                    )
                  }
                )
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:COMPREPLY)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (sh_array_literal
                            left: <Id.Op_LParen _>
                            words: [
                              {
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  command_list: 
                                    (command.CommandList
                                      children: [
                                        (C {<compgen>} {<-W>} {(DQ (${ Id.VSub_Name commands))} {<-->} 
                                          {(${ Id.VSub_Name cur)}
                                        )
                                      ]
                                    )
                                )
                              }
                            ]
                          )
                        }
                      spids: [588]
                    )
                  ]
                )
                (command.ControlFlow
                  token: <Id.ControlFlow_Return return>
                  arg_word: {<0>}
                )
              ]
            )
          ]
        )
    )
    (C {<complete>} {<-F>} {<_pkg-get>} {<pkg-get>})
  ]
)