# -*- shell-script -*- # set dollar0 sets $0 # # Copyright (C) 2011 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. # Load set0 if possible. if [[ -f $_Dbg_libdir/builtin/set0 ]] { enable -f $_Dbg_libdir/builtin/set0 set0 } # If it was set0 loaded, then we can add a debugger command "set dollar0" if enable -a set0 !2 >/dev/null { _Dbg_help_add_sub set dollar0 \ 'set dollar0 PROGRAM_NAME Set $0 to PROGRAM_NAME.' 1 proc _Dbg_do_set_dollar0 { # We use the loop below rather than _Dbg_set_args="(@)" because # we want to preserve embedded blanks in the arguments. if enable -a set0 !2 >/dev/null { set0 $1 } else { _Dbg_errmsg "Can't do becasue set0 module is not loaded." } return 0 } } (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_f child: {($ VSub_Name "$_Dbg_libdir") (/builtin/set0)} ) ) terminator: ) ] action: [(C {(enable)} {(-f)} {($ VSub_Name "$_Dbg_libdir") (/builtin/set0)} {(set0)})] spids: [-1 74] ) ] spids: [-1 86] ) (If arms: [ (if_arm cond: [ (Sentence child: (SimpleCommand words: [{(enable)} {(-a)} {(set0)}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[100])] ) terminator: ) ] action: [ (C {(_Dbg_help_add_sub)} {(set)} {(dollar0)} {(SQ <"set dollar0 PROGRAM_NAME\n"> <"\n"> <"Set $0 to PROGRAM_NAME.">)} {(1)} ) (FuncDef name: _Dbg_do_set_dollar0 body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (SimpleCommand words: [{(enable)} {(-a)} {(set0)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [150] ) ] ) terminator: ) ] action: [(C {(set0)} {(DQ ($ VSub_Number "$1"))})] spids: [-1 155] ) ] else_action: [ (C {(_Dbg_errmsg)} {(DQ ("Can't do becasue set0 module is not loaded."))}) ] spids: [165 175] ) (ControlFlow token: arg_word:{(0)}) ] spids: [131] ) spids: [127 130] ) ] spids: [-1 105] ) ] spids: [-1 185] ) ] )