the BASH debugger can print parts of your script’s source. When your script stops, the BASH debugger spontaneously prints the line where it stopped. Likewise, when you select a stack frame (see Selecting a frame), the BASH debugger prints the line where execution in that frame has stopped. You can print other portions of source files by explicit command.
If you use the BASH debugger through its GNU Emacs interface, you may prefer to use Emacs facilities to view source.
To print lines from a source file, use the list
command
(abbreviated l
). By default, ten lines are printed.
There are several ways to specify what part of the file you want to print.
Here are the forms of the list
command most commonly used:
list linenum
l linenum
Print lines centered around line number linenum in the current source file.
list function
l function
Print the text of function.
list
l
Print more lines. If the last lines printed were printed with a
list
command, this prints lines following the last lines
printed; however, if the last line printed was a solitary line printed
as part of displaying a stack frame (see Examining the
Stack), this prints lines centered around that line.
list -
l -
Print lines just before the lines last printed.
By default, the BASH debugger prints ten source lines with any of these forms of
the list
command.
You can change this using set listsize
:
set listsize count
¶Make the list
command display count source lines (unless
the list
argument explicitly specifies some other number).
show listsize
¶Display the number of lines that list
prints.
Repeating a list
command with RET discards the argument,
so it is equivalent to typing just list
. This is more useful
than listing the same lines again. An exception is made for an
argument of ‘-’; that argument is preserved in repetition so that
each repetition moves up in the source file.
In general, the list
command expects you to supply a
linespecs. Linespecs specify source lines; there are several ways
of writing them, but the effect is always to specify some source line.
Here is a complete description of the possible arguments for list
:
list linespec
Print lines centered around the line specified by linespec.
list first increment
Print increment lines starting from first
list first
Print lines starting with first.
list -
Print lines just before the lines last printed.
list .
Print lines after where the script is stopped.
list
As described in the preceding table.
Here are the ways of specifying a single source line—all the kinds of linespec.
number
Specifies line number of the current source file.
When a list
command has two linespecs, this refers to
the same source file as the first linespec.
filename:number
Specifies line number in the source file filename.
function
Specifies the line that function function is listed on.