This question提到如何在Bash函数中获取行号(也可能是脚本),但我想知道如何在Zsh中执行此操作。
答案 0 :(得分:2)
zsh
只使用LINENO:
LINENO <S> The line number of the current line within the current script, sourced file, or shell function being executed, whichever was started most recently. Note that in the case of shell functions the line number refers to the function as it appeared in the original definition, not necessarily as displayed by the func- tions builtin.