这个问题提到了如何在Bash函数(以及可能的脚本)中获取行号,但我想知道如何在Zsh中实现。
zsh
只使用 LINENO:
man zshparam
:
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.
PS4
变量中使用%i
表示相对行号,使用%I
表示绝对行号。 - pawamoy