# -*- shell-script -*- # subcmd.sh - Debugger Help Routines # # 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. # Command completion for a subcommand typeset -A _Dbg_next_complete proc _Dbg_complete_subcmd { # echo "level 0 called with comp_line: $COMP_LINE , comp_point: $COMP_POINT" typeset -a words; typeset subcmds setvar IFS = '' ',' words = ''( $COMP_LINE ) if (( ${#words[@]} == 1 )) { eval "subcmds=\${!_Dbg_debugger_$1_commands[@]}" setvar COMPREPLY = ''( $subcmds ) } elif (( ${#words[@]} == 2 )) { eval "subcmds=\${!_Dbg_debugger_$1_commands[@]}" typeset commands="${!_Dbg_command_help[@]}" setvar COMPREPLY = ''( $(compgen -W "$subcmds" "${words[1]}" ) ) if (( ${#COMPREPLY[@]} == 1 )) && [[ ${COMPREPLY[0]} == ${words[1]} ]] {' IFS=' '' typeset canon_line; setvar canon_line = "${words[@]}" if [[ -n ${_Dbg_next_complete[$canon_line]} && \ $COMP_LINE =~ ' '$ ]] { ${_Dbg_next_complete[$canon_line]} } } } elif [[ -n ${_Dbg_next_complete[$COMP_LINE]} ]] { ${_Dbg_next_complete[$COMP_LINE]} } else { setvar COMPREPLY = ''() } } proc _Dbg_complete_onoff { setvar COMPREPLY = ''(on off) }