$LINENO within functions

Stefan Farfeleder stefan at fafoe.narf.at
Fri May 30 17:44:33 UTC 2008


Hi,

SUSv3 says the following about $LINENO:

"Set by the shell to a decimal number representing the current
sequential line number (numbered starting with 1) within a script or
function before it executes each command. If the user unsets or resets
LINENO , the variable may lose its special meaning for the life of the
shell. If the shell is not currently executing a script or function, the
value of LINENO is unspecified. This volume of IEEE Std 1003.1-2001
specifies the effects of the variable only for systems supporting the
User Portability Utilities option."

My initial interpretation of "or function" was that it means $LINENO
within a function should be relative to the function's beginning line.
Now I'm not so sure anymore.  Bash release 2.05b changed the expansion
of $LINENO within functions to absolute numbering, stating this is
required by POSIX.  But then I wonder about the meaning of "or
function".  Does it mean functions in interactive scripts?  Because for
functions in shell scripts the mentioning of both "script" and
"function" seems redundant.

Stefan


More information about the freebsd-standards mailing list