diff --git a/command/info_sub/args_current.sh b/command/info_sub/args_current.sh new file mode 100644 index 0000000..6818163 --- /dev/null +++ b/command/info_sub/args_current.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# -*- shell-script -*- +# gdb-like "info args" 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. + +# Prints the current value of $@. + +_Dbg_help_add_sub info args_current \ + "**info args_current** + +Show the current values of \$@, modifications by the script are accounted for. + +See also: +--------- + +**backtrace**." 1 + +_Dbg_do_info_args_current() { + typeset -i n="${#_Dbg_arg[@]}" + typeset -i i + for ((i = 1; i <= n; i++)); do + _Dbg_printf "$%d = %s" "$i" "${_Dbg_arg[i]}" + done + return 0 +} diff --git a/lib/info.sh b/lib/info.sh index e300c8e..39fdddb 100644 --- a/lib/info.sh +++ b/lib/info.sh @@ -19,7 +19,7 @@ # the Free Software Foundation, 59 Temple Place, Suite 330, Boston, # MA 02111 USA. -typeset -r _Dbg_info_cmds='args breakpoints display files functions line program signals source stack variables warranty' +typeset -r _Dbg_info_cmds='args args_current breakpoints display files functions line program signals source stack variables warranty' _Dbg_info_help() { @@ -49,6 +49,11 @@ _Dbg_info_help() { case $subcmd in + args_current ) + _Dbg_msg \ +"info args_current -- Current values of variables \$1, \$2, ... of the current stack frame." + return 0 + ;; ar | arg | args ) _Dbg_msg \ "info args -- Argument variables (e.g. \$1, \$2, ...) of the current stack frame." diff --git a/test/data/misc-output-41.right b/test/data/misc-output-41.right index d4281f4..03bd5b0 100644 --- a/test/data/misc-output-41.right +++ b/test/data/misc-output-41.right @@ -149,6 +149,7 @@ output to go to STDOUT. List of info subcommands: ------------------------- info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame. +info args_current -- Current values of variables $1, $2, ... of the current stack frame. info breakpoints -- Status of user-settable breakpoints info display -- Show all display expressions info files -- Source files in the program @@ -162,9 +163,9 @@ info variables -- All global and static variable names info warranty -- Various kinds of warranty you do not have +info Info subcommands are: - args files line source warranty + args display handle signals variables + args_current files line source warranty breakpoints functions program stack watchpoints - display handle signals variables +#### history... +H 28: info @@ -220,6 +221,7 @@ help info List of info subcommands: ------------------------- info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame. +info args_current -- Current values of variables $1, $2, ... of the current stack frame. info breakpoints -- Status of user-settable breakpoints info display -- Show all display expressions info files -- Source files in the program @@ -273,6 +275,7 @@ help info List of info subcommands: ------------------------- info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame. +info args_current -- Current values of variables $1, $2, ... of the current stack frame. info breakpoints -- Status of user-settable breakpoints info display -- Show all display expressions info files -- Source files in the program diff --git a/test/data/misc-output-50.right b/test/data/misc-output-50.right index ef2444e..57512ef 100644 --- a/test/data/misc-output-50.right +++ b/test/data/misc-output-50.right @@ -150,6 +150,7 @@ output to go to STDOUT. List of info subcommands: ------------------------- info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame. +info args_current -- Current values of variables $1, $2, ... of the current stack frame. info breakpoints -- Status of user-settable breakpoints info display -- Show all display expressions info files -- Source files in the program @@ -163,9 +164,9 @@ info variables -- All global and static variable names info warranty -- Various kinds of warranty you do not have +info Info subcommands are: - args files line source warranty - breakpoints functions program stack watchpoints - display handle signals variables + args display handle signals variables + args_current files line source warranty + breakpoints functions program stack watchpoints +#### history... +H 28: info @@ -221,6 +222,7 @@ help info List of info subcommands: ------------------------- info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame. +info args_current -- Current values of variables $1, $2, ... of the current stack frame. info breakpoints -- Status of user-settable breakpoints info display -- Show all display expressions info files -- Source files in the program @@ -274,6 +276,7 @@ help info List of info subcommands: ------------------------- info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame. +info args_current -- Current values of variables $1, $2, ... of the current stack frame. info breakpoints -- Status of user-settable breakpoints info display -- Show all display expressions info files -- Source files in the program