From: Paul Eggert Date: Fri, 26 Oct 2001 19:52:07 +0000 (+0000) Subject: (Special Shell Variables): Document some X-Git-Tag: AUTOCONF-2.52f~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=34d266fd6995bbd41736d7b84466bef260988185;p=thirdparty%2Fautoconf.git (Special Shell Variables): Document some more LINENO gotchas, particularly with respect to the Awk+Sed hack. --- diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 209097ae6..02932ad14 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -8187,10 +8187,19 @@ builtin @command{unset}, for more details. @item LINENO @evindex LINENO Most modern shells provide the current line number in @code{LINENO}. -Its value is the line number of the beginning of the current command -(see below the output of the here document). The behavior wrt -@command{eval} differs according to the shell, but, amusingly, not in -the case of sub shells: +Its value is the line number of the beginning of the current command. +Autoconf attempts to execute @command{configure} with a modern shell. +If no such shell is available, it attempts to implement @code{LINENO} +with a simple Awk+Sed prepass that replaces the first instance of the +string @code{$LINENO} in each line with the line's number. + +You should not rely on @code{LINENO} within @command{eval}, as the +behavior differs in practice. Also, the possibility of the Awk+Sed +prepass means that you should not rely on @code{$LINENO} when quoted, +when in here-documents, or when in long commands that cross line +boundaries or that have multiple instances of $LINENO. Subshells +should be OK, though. In the following example, lines 1, 6, and 10 +are portable, but the other instances of @code{LINENO} are not: @example @group @@ -8202,30 +8211,34 @@ cat < @kbd{sed '/\$LINENO/s/^\([^:]*\):\(.*\)\$LINENO/\2\1/' |} +> @kbd{sh} +1. 1 +3. 3 +4. 4 +6. 6 +7. 7 +8. 8 +9. 9 +10. 10 +11. 11 @end group @end example