autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Ditch _AS_LINENO_PREPARE from _AS_PREPARE


From: Eric Blake
Subject: Re: [PATCH] Ditch _AS_LINENO_PREPARE from _AS_PREPARE
Date: Thu, 30 Oct 2008 17:16:48 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> Yes.  Although I'd like to see a little bit of documentation in the manual 
> about the fact that child scripts created by AS_INIT_GENERATED may report 
> $LINENO in relation to the parent's line numbers, depending on the 
capabilities 
> of the shell.

Like so, now committed:

From: Eric Blake <address@hidden>
Date: Thu, 30 Oct 2008 10:56:11 -0600
Subject: [PATCH] Update LINENO documentation.

* doc/autoconf.texi (Initialization Macros) <AS_INIT_GENERATED>:
(Special Shell Variables) <LINENO>: Mention that LINENO support in
child scripts may be broken.  Modernize example.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog         |    7 +++
 doc/autoconf.texi |  123 ++++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 95 insertions(+), 35 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a9556b8..64afd8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-10-30  Eric Blake  <address@hidden>
 
+       Update LINENO documentation.
+       * doc/autoconf.texi (Initialization Macros) <AS_INIT_GENERATED>:
+       (Special Shell Variables) <LINENO>: Mention that LINENO support in
+       child scripts may be broken.  Modernize example.
+
+2008-10-30  Eric Blake  <address@hidden>
+
        Don't check for non-POSIX extensions in suggested tests.
        * lib/m4sugar/m4sh.m4 (_AS_VAR_APPEND_WORKS): Remove suggestion;
        we still use += if available, but should not reject shells (like
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index d2997ef..f10eeae 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -12323,6 +12323,11 @@ Initialization Macros
 
 This, however, may change in the future as the M4sh interface is
 stabilized further.
+
+Also, be aware that use of @env{LINENO} within the child script may
+report line numbers relative to their location in the parent script,
+even when using @code{AS_LINENO_PREPARE}, if the parent script was
+unable to locate a shell with working @env{LINENO} support.
 @end defmac
 
 @defmac AS_LINENO_PREPARE
@@ -14425,59 +14430,95 @@ Special Shell Variables
 your script; configure scripts do this automatically in @code{AC_INIT}.
 
 You should not rely on @code{LINENO} within @command{eval} or shell
-functions, as the behavior differs in practice.  Also, the possibility
-of the 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.  Subshells should be OK, though.  In the following example,
-lines 1, 6, and 9 are portable, but the other instances of @code{LINENO}
-are not:
+functions, as the behavior differs in practice.  The presence of a
+quoted newline within simple commands can alter which line number is
+used as the starting point for @code{$LINENO} substitutions within that
+command.  Also, the possibility of the Sed prepass means that you should
+not rely on @code{$LINENO} when quoted, when in here-documents, or when
+line continuations are used.  Subshells should be OK, though.  In the
+following example, lines 1, 9, and 14 are portable, but the other
+instances of @code{$LINENO} do not have deterministic values:
 
 @example
 @group
 $ @kbd{cat lineno}
 echo 1. $LINENO
+echo "2. $LINENO
+3. $LINENO"
 cat <<EOF
-3. $LINENO
-4. $LINENO
+5. $LINENO
+6. $LINENO
+7. \$LINENO
 EOF
-( echo 6. $LINENO )
-eval 'echo 7. $LINENO'
-echo 8. '$LINENO'
-echo 9. $LINENO '
-10.' $LINENO
+( echo 9. $LINENO )
+eval 'echo 10. $LINENO'
+eval 'echo 11. $LINENO
+echo 12. $LINENO'
+echo 13. '$LINENO'
+echo 14. $LINENO '
+15.' $LINENO
+f () @{ echo $1 $LINENO;
+echo $1 $LINENO @}
+f 18.
+echo 19. \
+$LINENO
 @end group
 @group
-$ @kbd{bash-2.05 lineno}
+$ @kbd{bash-3.2 ./lineno}
 1. 1
-3. 2
-4. 2
-6. 6
-7. 1
-8. $LINENO
+2. 3
+3. 3
+5. 4
+6. 4
+7. $LINENO
 9. 9
-10. 9
+10. 10
+11. 12
+12. 13
+13. $LINENO
+14. 14
+15. 14
+18. 16
+18. 17
+19. 19
 @end group
 @group
-$ @kbd{zsh-3.0.6 lineno}
+$ @kbd{zsh-4.3.4 ./lineno}
 1. 1
+2. 2
 3. 2
-4. 2
-6. 6
-7. 7
-8. $LINENO
+5. 4
+6. 4
+7. $LINENO
 9. 9
-10. 9
+10. 1
+11. 1
+12. 2
+13. $LINENO
+14. 14
+15. 14
+18. 0
+18. 1
+19. 19
 @end group
 @group
-$ @kbd{pdksh-5.2.14 lineno}
+$ @kbd{pdksh-5.2.14 ./lineno}
 1. 1
+2. 2
 3. 2
-4. 2
-6. 6
-7. 0
-8. $LINENO
+5. 4
+6. 4
+7. $LINENO
 9. 9
-10. 9
+10. 0
+11. 0
+12. 0
+13. $LINENO
+14. 14
+15. 14
+18. 16
+18. 17
+19. 19
 @end group
 @group
 $ @kbd{sed '=' <lineno |}
@@ -14493,16 +14534,28 @@ Special Shell Variables
 > @kbd{  ' |}
 > @kbd{  sh}
 1. 1
+2. 2
 3. 3
-4. 4
+5. 5
 6. 6
-7. 7
-8. 8
+7. \7
 9. 9
 10. 10
+11. 11
+12. 12
+13. 13
+14. 14
+15. 15
+18. 16
+18. 17
+19. 20
 @end group
 @end example
 
+In particular, note that @file{config.status} (and any other subsidiary
+script created by @code{AS_INIT_GENERATED}) might report line numbers
+relative to the parent script as a result of the potential Sed pass.
+
 @item NULLCMD
 @evindex NULLCMD
 When executing the command @samp{>foo}, @command{zsh} executes
-- 
1.6.0.2








reply via email to

[Prev in Thread] Current Thread [Next in Thread]