Skip to content

Commit a6a3634

Browse files
committed
BashSupport Pro: Implement "info args_current" to show the current values of $1, $2, ... of the current frame
1 parent 531053d commit a6a3634

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

command/info_sub/args_current.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
# -*- shell-script -*-
3+
# gdb-like "info args" debugger command
4+
#
5+
# Copyright (C) 2010-2011, 2016 Rocky Bernstein <[email protected]>
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License as
9+
# published by the Free Software Foundation; either version 2, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
# General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; see the file COPYING. If not, write to
19+
# the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20+
# MA 02111 USA.
21+
22+
# Prints the current value of $@.
23+
24+
_Dbg_help_add_sub info args_current \
25+
"**info args_current**
26+
27+
Show the current values of \$@, modifications by the script are accounted for.
28+
29+
See also:
30+
---------
31+
32+
**backtrace**." 1
33+
34+
_Dbg_do_info_args_current() {
35+
typeset -i n="${#_Dbg_arg[@]}"
36+
typeset -i i
37+
for ((i = 1; i <= n; i++)); do
38+
_Dbg_printf "$%d = %s" "$i" "${_Dbg_arg[i]}"
39+
done
40+
return 0
41+
}

lib/info.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
2020
# MA 02111 USA.
2121

22-
typeset -r _Dbg_info_cmds='args breakpoints display files functions line program signals source stack variables warranty'
22+
typeset -r _Dbg_info_cmds='args args_current breakpoints display files functions line program signals source stack variables warranty'
2323

2424
_Dbg_info_help() {
2525

@@ -49,6 +49,11 @@ _Dbg_info_help() {
4949

5050

5151
case $subcmd in
52+
args_current )
53+
_Dbg_msg \
54+
"info args_current -- Current values of variables \$1, \$2, ... of the current stack frame."
55+
return 0
56+
;;
5257
ar | arg | args )
5358
_Dbg_msg \
5459
"info args -- Argument variables (e.g. \$1, \$2, ...) of the current stack frame."

test/data/misc-output-41.right

+5-2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ output to go to STDOUT.
149149
List of info subcommands:
150150
-------------------------
151151
info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame.
152+
info args_current -- Current values of variables $1, $2, ... of the current stack frame.
152153
info breakpoints -- Status of user-settable breakpoints
153154
info display -- Show all display expressions
154155
info files -- Source files in the program
@@ -162,9 +163,9 @@ info variables -- All global and static variable names
162163
info warranty -- Various kinds of warranty you do not have
163164
+info
164165
Info subcommands are:
165-
args files line source warranty
166+
args display handle signals variables
167+
args_current files line source warranty
166168
breakpoints functions program stack watchpoints
167-
display handle signals variables
168169
+#### history...
169170
+H
170171
28: info
@@ -215,6 +216,7 @@ Info subcommands are:
215216
List of info subcommands:
216217
-------------------------
217218
info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame.
219+
info args_current -- Current values of variables $1, $2, ... of the current stack frame.
218220
info breakpoints -- Status of user-settable breakpoints
219221
info display -- Show all display expressions
220222
info files -- Source files in the program
@@ -266,6 +268,7 @@ Invalid history number: foo
266268
List of info subcommands:
267269
-------------------------
268270
info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame.
271+
info args_current -- Current values of variables $1, $2, ... of the current stack frame.
269272
info breakpoints -- Status of user-settable breakpoints
270273
info display -- Show all display expressions
271274
info files -- Source files in the program

0 commit comments

Comments
 (0)