(command.CommandList
  children: [
    (C {<typeset>} {<-i>} {<Id.Lit_VarLike '_Dbg_hi_last_stop='> <0>})
    (C {<typeset>} {<-i>} {<Id.Lit_VarLike '_Dbg_hi='> <0>})
    (command.CommandList
      children: [
        (command.Sentence
          child: (C {<typeset>} {<-a>} {<_Dbg_history>})
          terminator: <Id.Op_Semi _>
        )
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:_Dbg_history)
              op: assign_op.Equal
              rhs: {(sh_array_literal left:<Id.Op_LParen _>)}
              spids: [85]
            )
          ]
        )
      ]
    )
    (C {<typeset>} {<-i>} {<Id.Lit_VarLike '_Dbg_set_history='> <1>})
    (C {<typeset>} {<-i>} 
      {<Id.Lit_VarLike '_Dbg_history_length='> 
        (braced_var_sub
          token: <Id.VSub_Name HISTSIZE>
          suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:{<256>})
        )
      }
    )
    (C {<typeset>} 
      {<Id.Lit_VarLike '_Dbg_histfile='> 
        (braced_var_sub
          token: <Id.VSub_Name HOME>
          suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:{<.>})
        ) <'/.bashdb_hist'>
      }
    )
    (command.ShFunction
      name: _Dbg_history_parse
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:history_num)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_Number '$1')}
                  spids: [145]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.DParen
                  child: 
                    (arith_expr.Binary
                      op_id: Id.Arith_Less
                      left: <Id.Lit_ArithVarLike history_num>
                      right: {<Id.Lit_Digits 0>}
                    )
                )
                (command.DParen
                  child: 
                    (arith_expr.BinaryAssign
                      op_id: Id.Arith_Equal
                      left: <Id.Lit_ArithVarLike history_num>
                      right: 
                        (arith_expr.Binary
                          op_id: Id.Arith_Plus
                          left: 
                            (arith_expr.Binary
                              op_id: Id.Arith_Minus
                              left: 
                                {
                                  (braced_var_sub
                                    token: <Id.VSub_Name _Dbg_history>
                                    prefix_op: (Id.VSub_Pound)
                                    bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At)
                                  )
                                }
                              right: {<Id.Lit_Digits 1>}
                            )
                          right: {($ Id.VSub_Number '$1')}
                        )
                    )
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:_Dbg_hi)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (braced_var_sub
                        token: <Id.VSub_Name _Dbg_history>
                        prefix_op: (Id.VSub_Pound)
                        bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At)
                      )
                    }
                  spids: [179]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.DBracket
                  expr: 
                    (bool_expr.Unary
                      op_id: Id.BoolUnary_z
                      child: {($ Id.VSub_DollarName '$history_num')}
                    )
                )
                (C {<let>} {<Id.Lit_VarLike 'history_num='> ($ Id.VSub_DollarName '$_Dbg_hi') <-1>})
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.DBracket
                              expr: 
                                (bool_expr.Binary
                                  op_id: Id.BoolBinary_GlobDEqual
                                  left: {($ Id.VSub_DollarName '$_Dbg_cmd')}
                                  right: {<h> <Id.Lit_Other '*'>}
                                )
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: 
                            (condition.Shell
                              commands: [
                                (command.Sentence
                                  child: 
                                    (command.DBracket
                                      expr: 
                                        (bool_expr.Binary
                                          op_id: Id.BoolBinary_GlobNEqual
                                          left: {($ Id.VSub_DollarName '$history_num')}
                                          right: {($ Id.VSub_DollarName '$int_pat')}
                                        )
                                    )
                                  terminator: <Id.Op_Semi _>
                                )
                              ]
                            )
                          action: [
                            (command.If
                              arms: [
                                (if_arm
                                  cond: 
                                    (condition.Shell
                                      commands: [
                                        (command.Sentence
                                          child: 
                                            (command.DBracket
                                              expr: 
                                                (bool_expr.Binary
                                                  op_id: Id.BoolBinary_GlobDEqual
                                                  left: {($ Id.VSub_DollarName '$history_num')}
                                                  right: {<-> ($ Id.VSub_DollarName '$int_pat')}
                                                )
                                            )
                                          terminator: <Id.Op_Semi _>
                                        )
                                      ]
                                    )
                                  action: [
                                    (command.ShAssignment
                                      pairs: [
                                        (assign_pair
                                          lhs: (sh_lhs_expr.Name name:history_num)
                                          op: assign_op.Equal
                                          rhs: 
                                            {($ Id.VSub_DollarName '$_Dbg_hi') <Id.Lit_Other '+'> 
                                              ($ Id.VSub_DollarName '$history_num')
                                            }
                                          spids: [260]
                                        )
                                      ]
                                    )
                                  ]
                                  spids: [242 257]
                                )
                              ]
                              else_action: [
                                (C {<_Dbg_errmsg>} 
                                  {
                                    (DQ <'Invalid history number skipped: '> 
                                      ($ Id.VSub_DollarName '$history_num')
                                    )
                                  }
                                )
                                (command.ShAssignment
                                  pairs: [
                                    (assign_pair
                                      lhs: (sh_lhs_expr.Name name:history_num)
                                      op: assign_op.Equal
                                      rhs: {<-1>}
                                      spids: [277]
                                    )
                                  ]
                                )
                              ]
                            )
                          ]
                          spids: [225 239]
                        )
                      ]
                    )
                  ]
                  spids: [207 222]
                )
              ]
              else_action: [(C {<Id.Lit_Colon ':'>})]
            )
          ]
        )
    )
    (command.ShFunction
      name: _Dbg_history_read
      body: 
        (BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.DBracket
                              expr: 
                                (bool_expr.Unary
                                  op_id: Id.BoolUnary_r
                                  child: {($ Id.VSub_DollarName '$_Dbg_histfile')}
                                )
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (C {<history>} {<-r>} {($ Id.VSub_DollarName '$_Dbg_histfile')})
                    (command.Sentence
                      child: (C {<typeset>} {<-a>} {<last_history>})
                      terminator: <Id.Op_Semi _>
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:last_history)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (sh_array_literal
                                left: <Id.Op_LParen _>
                                words: [
                                  {
                                    (command_sub
                                      left_token: <Id.Left_DollarParen '$('>
                                      child: (C {<history>} {<1>})
                                    )
                                  }
                                ]
                              )
                            }
                          spids: [506]
                        )
                      ]
                    )
                    (C {<typeset>} {<-i>} 
                      {<Id.Lit_VarLike 'max_history='> 
                        (braced_var_sub
                          token: <Id.VSub_Name last_history>
                          bracket_op: (bracket_op.ArrayIndex expr:{<Id.Lit_Digits 0>})
                        )
                      }
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: 
                            (condition.Shell
                              commands: [
                                (command.Sentence
                                  child: 
                                    (command.DParen
                                      child: 
                                        (arith_expr.Binary
                                          op_id: Id.Arith_Great
                                          left: <Id.Lit_ArithVarLike max_history>
                                          right: <Id.Lit_ArithVarLike _Dbg_history_length>
                                        )
                                    )
                                  terminator: <Id.Op_Semi _>
                                )
                              ]
                            )
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:max_history)
                                  op: assign_op.Equal
                                  rhs: {($ Id.VSub_DollarName '$_Dbg_history_length')}
                                  spids: [547]
                                )
                              ]
                            )
                          ]
                          spids: [529 544]
                        )
                      ]
                    )
                    (C {<local>} 
                      {<Id.Lit_VarLike 'OLD_HISTTIMEFORMAT='> (${ Id.VSub_Name HISTTIMEFORMAT)}
                    )
                    (C {<local>} {<hist>})
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:HISTTIMEFORMAT)
                          op: assign_op.Equal
                          rhs: {(SQ )}
                          spids: [567]
                        )
                      ]
                    )
                    (C {<local>} {<-i>} {<i>})
                    (command.ForExpr
                      init: 
                        (arith_expr.BinaryAssign
                          op_id: Id.Arith_Equal
                          left: <Id.Lit_ArithVarLike i>
                          right: {<Id.Lit_Digits 1>}
                        )
                      cond: 
                        (arith_expr.Binary
                          op_id: Id.Arith_LessEqual
                          left: <Id.Lit_ArithVarLike i>
                          right: <Id.Lit_ArithVarLike max_history>
                        )
                      update: 
                        (arith_expr.UnaryAssign
                          op_id: Id.Node_PostDPlus
                          child: <Id.Lit_ArithVarLike i>
                        )
                      body: 
                        (command.DoGroup
                          children: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:last_history)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (sh_array_literal
                                        left: <Id.Op_LParen _>
                                        words: [
                                          {
                                            (command_sub
                                              left_token: <Id.Left_DollarParen '$('>
                                              child: (C {<history>} {($ Id.VSub_DollarName '$i')})
                                            )
                                          }
                                        ]
                                      )
                                    }
                                  spids: [613]
                                )
                              ]
                            )
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:hist)
                                  op: assign_op.Equal
                                  rhs: 
                                    {(${ Id.VSub_Name last_history) <Id.Lit_LBracket '['> <1> 
                                      <Id.Lit_RBracket ']'>
                                    }
                                  spids: [623]
                                )
                              ]
                            )
                          ]
                        )
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:HISTTIMEFORMAT)
                          op: assign_op.Equal
                          rhs: {(${ Id.VSub_Name OLD_HISTTIMEFORMAT)}
                          spids: [639]
                        )
                      ]
                    )
                  ]
                  spids: [477 489]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: _Dbg_history_write
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.DParen
                  child: 
                    (arith_expr.Binary
                      op_id: Id.Arith_DAmp
                      left: 
                        (arith_expr.Binary
                          op_id: Id.Arith_Great
                          left: <Id.Lit_ArithVarLike _Dbg_history_length>
                          right: {<Id.Lit_Digits 0>}
                        )
                      right: <Id.Lit_ArithVarLike _Dbg_set_history>
                    )
                )
                (C {<history>} {<-w>} {($ Id.VSub_DollarName '$_Dbg_histfile')})
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: _Dbg_history_remove_item
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:_Dbg_hi)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (braced_var_sub
                        token: <Id.VSub_Name _Dbg_history>
                        prefix_op: (Id.VSub_Pound)
                        bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At)
                      ) <-1>
                    }
                  spids: [697]
                )
              ]
            )
            (C {<unset>} 
              {<Id.Lit_ArrayLhsOpen '_Dbg_history['> ($ Id.VSub_DollarName '$_Dbg_hi') 
                <Id.Lit_RBracket ']'>
              }
            )
          ]
        )
    )
  ]
)