Menu

[0c50c7]: / command / list.sh  Maximize  Restore  History

Download this file

103 lines (84 with data), 3.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
# -*- shell-script -*-
# list.sh - Some listing commands
#
# Copyright (C) 2002-2006, 2008-2011, 2016
#
# 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.
_Dbg_help_add list \
'**list**[**>**] [*location*|**.**|**-**] [*count*]
List source code.
Without arguments, print lines centered around the current line. If
*location* is given, that number of lines is shown.
*location* can be a read-in function name or a filename and line
number separated by a colon, e.g /etc/profile:5
If *count* is omitted, use the value in the **set listize** setting as
a count. Use **set listsize** to change this setting. If *count* is
given and is less than the starting line, then it is treated as a
count. Otherwise it is treated as an ending line number.
more generally when the alias ends in ">", rather than center lines
around *location* that will be used as the starting point.
Examples:
---------
list # List from current program position or where we last left off
list 5 # List starting from line 5
list 5 2 # List two lines starting from line 5
list . # List lines centered from where we currently are stopped
list - # List lines previous to those just shown
See also:
---------
**set listsize** or **show listsize** to see or set the value;
**set autolist**.
'
# l [start|.] [cnt] List cnt lines from line start.
# l sub List source code fn
_Dbg_do_list() {
typeset -i center_line
if [[ ${_Dbg_orig_cmd:${#_Dbg_orig_cmd}-1:1} == '>' ]] ; then
center_line=0
else
center_line=1
fi
typeset first_arg
if (( $# > 0 )) ; then
first_arg="$1"
shift
else
first_arg="$_Dbg_listline"
fi
if [[ $first_arg == '.' ]] || [[ $first_arg == '-' ]] ; then
_Dbg_list $center_line "$_Dbg_frame_last_filename" $first_arg "$*"
_Dbg_last_cmd="$_Dbg_cmd"
return 0
fi
typeset filename
typeset -i line_number
typeset full_filename
_Dbg_linespec_setup "$first_arg"
if [[ -n $full_filename ]] ; then
(( line_number == 0 )) && line_number=1
_Dbg_check_line $line_number "$full_filename"
(( $? == 0 )) && \
_Dbg_list $center_line "$full_filename" "$line_number" $*
_Dbg_last_cmd="$_Dbg_cmd"
return 0
else
_Dbg_file_not_read_in "$filename"
return 3
fi
}
_Dbg_alias_add l list
_Dbg_alias_add "l>" list
_Dbg_alias_add "list>" list
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.