# -*- shell-script -*- # "set history" debugger command # # Copyright (C) 2010-2011, 2016 Rocky Bernstein # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, 59 Temple Place, Suite 330, Boston, # MA 02111 USA. _Dbg_help_add_sub set history \ '**set history save** [**on**|**off**] **set history size** *num* **set history filename** *path* In the first form, set whether to save history. In the second form, how many history lines to save is indicated. In the third form, the place to store the history file is given. ' _Dbg_next_complete[set history]='_Dbg_complete_history' proc _Dbg_complete_history { global COMPREPLY := '('save size) } proc _Dbg_do_set_history { matchstr $1 { sa | sav | save { typeset onoff=$(2:-'on') matchstr $onoff { on | 1 { _Dbg_write_journal_eval "_Dbg_set_history=1" } off | 0 { _Dbg_write_journal_eval "_Dbg_set_history=0" } * { _Dbg_errmsg "\"on\" or \"off\" expected." return 1 } } } si | siz | size { eval $_seteglob if [[ -z $2 ]] { _Dbg_errmsg "Argument required (integer to set it to.)." } elif [[ $2 != $int_pat ]] { _Dbg_errmsg "Integer argument expected; got: $2" eval $_resteglob return 1 } eval $_resteglob _Dbg_write_journal_eval "_Dbg_history_length=$2" } * { _Dbg_errmsg "\"save\", or \"size\" expected." return 1 } } return 0 } (CommandList children: [ (C {(_Dbg_help_add_sub)} {(set)} {(history)} { (SQ <"**set history save** [**on**|**off**]\n"> <"\n"> <"**set history size** *num*\n"> <"\n"> <"**set history filename** *path*\n"> <"\n"> <"In the first form, set whether to save history.\n"> <"\n"> <"In the second form, how many history lines to save is indicated.\n"> <"\n"> <"In the third form, the place to store the history file is given.\n"> ) } ) (C {(_Dbg_next_complete) (Lit_Other "[") (set)} {(history) (Lit_Other "]") (Lit_Other "=") (SQ <_Dbg_complete_history>)} ) (FuncDef name: _Dbg_complete_history body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COMPREPLY) op: Equal rhs: {(ArrayLiteralPart words:[{(save)}{(size)}])} spids: [99] ) ] spids: [99] ) ] spids: [96] ) spids: [92 95] ) (FuncDef name: _Dbg_do_set_history body: (BraceGroup children: [ (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list: [{(sa)} {(sav)} {(save)}] action: [ (C {(typeset)} {(Lit_VarLike "onoff=") (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [141 147] ) } ) (Case to_match: {($ VSub_Name "$onoff")} arms: [ (case_arm pat_list: [{(on)} {(1)}] action: [(C {(_Dbg_write_journal_eval)} {(DQ ("_Dbg_set_history=1"))})] spids: [157 163 173 -1] ) (case_arm pat_list: [{(off)} {(0)}] action: [(C {(_Dbg_write_journal_eval)} {(DQ ("_Dbg_set_history=0"))})] spids: [176 182 192 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (C {(_Dbg_errmsg)} { (DQ (EscapedLiteralPart token:) (on) (EscapedLiteralPart token: ) (" or ") (EscapedLiteralPart token:) (off) (EscapedLiteralPart token: ) (" expected.") ) } ) (ControlFlow token: arg_word: {(1)} ) ] spids: [195 197 219 -1] ) ] spids: [150 154 222] ) ] spids: [125 135 225 -1] ) (case_arm pat_list: [{(si)} {(siz)} {(size)}] action: [ (C {(eval)} {(DQ ($ VSub_Name "$_seteglob"))}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id:BoolUnary_z child:{($ VSub_Number "$2")}) ) terminator: ) ] action: [ (C {(_Dbg_errmsg)} {(DQ ("Argument required (integer to set it to.)."))}) ] spids: [-1 260] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Number "$2")} right: {($ VSub_Name "$int_pat")} ) ) terminator: ) ] action: [ (C {(_Dbg_errmsg)} {(DQ ("Integer argument expected; got: ") ($ VSub_Number "$2"))} ) (C {(eval)} {(DQ ($ VSub_Name "$_resteglob"))}) (ControlFlow token: arg_word: {(1)} ) ] spids: [270 284] ) ] spids: [-1 307] ) (C {(eval)} {(DQ ($ VSub_Name "$_resteglob"))}) (C {(_Dbg_write_journal_eval)} {(DQ ("_Dbg_history_length=") ($ VSub_Number "$2"))}) ] spids: [228 238 325 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (C {(_Dbg_errmsg)} { (DQ (EscapedLiteralPart token:) (save) (EscapedLiteralPart token: ) (", or ") (EscapedLiteralPart token:) (size) (EscapedLiteralPart token: ) (" expected.") ) } ) (ControlFlow token: arg_word:{(1)}) ] spids: [328 329 351 -1] ) ] spids: [116 122 354] ) (ControlFlow token: arg_word:{(0)}) ] spids: [113] ) spids: [109 112] ) ] )