Skip to content

Commit

Permalink
BashSupport Pro: Implement "info args_current" to show the current va…
Browse files Browse the repository at this point in the history
…lues of $1, $2, ... of the current frame
  • Loading branch information
jansorg committed Oct 9, 2024
1 parent 332f4e6 commit 0c3a385
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
41 changes: 41 additions & 0 deletions command/info_sub/args_current.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# -*- shell-script -*-
# gdb-like "info args" debugger command
#
# Copyright (C) 2010-2011, 2016 Rocky Bernstein <[email protected]>
#
# 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
}
7 changes: 6 additions & 1 deletion lib/info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -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."
Expand Down
7 changes: 5 additions & 2 deletions test/data/misc-output-41.right
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions test/data/misc-output-50.right
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c3a385

Please sign in to comment.