2010-09-13 38 views
1

我正在写一个相当大的shell脚本。有没有办法从该脚本打印脚本的行号?基本上我想有类似于gcc LINE宏的东西。这将帮助我调试我的脚本。__LINE__等价于Linux shell

由于提前,

Souvik

回答

2

也许这有助于一点点:

http://www.network-theory.co.uk/docs/bashref/BashVariables.html

BASH_LINENO 
    An array variable whose members are the line numbers in source files corresponding to each member of FUNCNAME. ${BASH_LINENO[$i]} is the line number in the source file where ${FUNCNAME[$i]} was called. The corresponding source file name is ${BASH_SOURCE[$i]}. Use LINENO to obtain the current line number. 
0

$LINENO变量返回在其中使用该变量行。