2010-09-13 57 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變量返回在其中使用該變量行。