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