Date: Fri, 30 May 2008 21:12:42 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Stefan Farfeleder <stefan@fafoe.narf.at> Cc: freebsd-standards@freebsd.org Subject: Re: $LINENO within functions Message-ID: <20080530181242.GC21317@deviant.kiev.zoral.com.ua> In-Reply-To: <20080530172711.GA1056@lizard.fafoe.narf.at> References: <20080530172711.GA1056@lizard.fafoe.narf.at>
next in thread | previous in thread | raw e-mail | index | archive | help
--Ytgo/kJyDF3J5kSH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 30, 2008 at 07:27:12PM +0200, Stefan Farfeleder wrote: > Hi, >=20 > SUSv3 says the following about $LINENO: >=20 > "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." >=20 > 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. I do not know whether you need this data, but ksh93 and pdksh exhibit the same behaviour as bash. For the rev. 1.1 of lineno.0, I got 2 3 6 7 12 13 foo foo 2 On the other hand, zsh produces 2 3 1 2 12 13 foo foo 2 --Ytgo/kJyDF3J5kSH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkhAQ5kACgkQC3+MBN1Mb4gWtACeP2F4UcaZwQFkNEzZcYmApo8y hpsAmwSC7SJE/s5CajEgkYAknmkBVom8 =RZG6 -----END PGP SIGNATURE----- --Ytgo/kJyDF3J5kSH--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080530181242.GC21317>