# -*- shell-script -*- # info.sh - gdb-like "info" debugger commands # # Copyright (C) 2002-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. typeset -A _Dbg_debugger_info_commands typeset -A _Dbg_command_help_info _Dbg_help_add info '' 1 _Dbg_complete_info # Load in "info" subcommands for _Dbg_file in [$(_Dbg_libdir)/command/info_sub/*.sh] { source $_Dbg_file } # Command completion proc _Dbg_complete_info { _Dbg_complete_subcmd info } proc _Dbg_do_info { if sh-expr '$# > 0)' { typeset subcmd=$1 shift if [[ -n ${_Dbg_debugger_info_commands[$subcmd]} ]] { $(_Dbg_debugger_info_commands[$subcmd]) @Argv return $? } else { # Look for a unique abbreviation typeset -i count=0 typeset list; setglobal list = $(!_Dbg_debugger_info_commands[@]) for try in [$list] { if [[ $try =~ ^$subcmd ]] { setglobal subcmd = $try sh-expr 'count++' } } sh-expr 'found=(count==1)' } if sh-expr 'found' { $(_Dbg_debugger_info_commands[$subcmd]) @Argv return $? } _Dbg_errmsg "Unknown info subcommand: $subcmd" setglobal msg = '_Dbg_errmsg' } else { setglobal msg = '_Dbg_msg' } typeset -a list setglobal list = ''(${!_Dbg_debugger_info_commands[@]}) sort_list 0 $(#list[@])-1 typeset columnized='' typeset -i width; sh-expr 'width=_Dbg_set_linewidth-5' typeset -a columnized; columnize $width typeset -i i $msg "Info subcommands are:" for ((i=0; i<${#columnized[@]}; i++)) ; do $msg " ${columnized[i]}" done return 1 } _Dbg_alias_add i info