Skip to content

Commit 0c3a385

Browse files
committed
BashSupport Pro: Implement "info args_current" to show the current values of $1, $2, ... of the current frame
1 parent 332f4e6 commit 0c3a385

File tree

4 files changed

+58
-6
lines changed

4 files changed

+58
-6
lines changed

command/info_sub/args_current.sh

Lines changed: 41 additions & 0 deletions
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 <rocky@gnu.org>
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

Lines changed: 6 additions & 1 deletion
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

Lines changed: 5 additions & 2 deletions
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
@@ -220,6 +221,7 @@ help info
220221
List of info subcommands:
221222
-------------------------
222223
info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame.
224+
info args_current -- Current values of variables $1, $2, ... of the current stack frame.
223225
info breakpoints -- Status of user-settable breakpoints
224226
info display -- Show all display expressions
225227
info files -- Source files in the program
@@ -273,6 +275,7 @@ help info
273275
List of info subcommands:
274276
-------------------------
275277
info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame.
278+
info args_current -- Current values of variables $1, $2, ... of the current stack frame.
276279
info breakpoints -- Status of user-settable breakpoints
277280
info display -- Show all display expressions
278281
info files -- Source files in the program

test/data/misc-output-50.right

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ output to go to STDOUT.
150150
List of info subcommands:
151151
-------------------------
152152
info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame.
153+
info args_current -- Current values of variables $1, $2, ... of the current stack frame.
153154
info breakpoints -- Status of user-settable breakpoints
154155
info display -- Show all display expressions
155156
info files -- Source files in the program
@@ -163,9 +164,9 @@ info variables -- All global and static variable names
163164
info warranty -- Various kinds of warranty you do not have
164165
+info
165166
Info subcommands are:
166-
args files line source warranty
167-
breakpoints functions program stack watchpoints
168-
display handle signals variables
167+
args display handle signals variables
168+
args_current files line source warranty
169+
breakpoints functions program stack watchpoints
169170
+#### history...
170171
+H
171172
28: info
@@ -221,6 +222,7 @@ help info
221222
List of info subcommands:
222223
-------------------------
223224
info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame.
225+
info args_current -- Current values of variables $1, $2, ... of the current stack frame.
224226
info breakpoints -- Status of user-settable breakpoints
225227
info display -- Show all display expressions
226228
info files -- Source files in the program
@@ -274,6 +276,7 @@ help info
274276
List of info subcommands:
275277
-------------------------
276278
info args -- Argument variables (e.g. $1, $2, ...) of the current stack frame.
279+
info args_current -- Current values of variables $1, $2, ... of the current stack frame.
277280
info breakpoints -- Status of user-settable breakpoints
278281
info display -- Show all display expressions
279282
info files -- Source files in the program

0 commit comments

Comments
 (0)