autoconf-commit
[Top][All Lists]
Advanced

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

[SCM] GNU Autoconf source repository branch, master, updated. v2.61a-307


From: Ralf Wildenhues
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.61a-307-ga13f9b7
Date: Thu, 22 Nov 2007 07:11:56 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Autoconf source repository".

http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=a13f9b79a63880992b1486e42976398c84feae8b

The branch, master has been updated
       via  a13f9b79a63880992b1486e42976398c84feae8b (commit)
       via  844f7708855438ea616629db96544f7523c5f400 (commit)
      from  33df9071f5405af99992ad63e8628490920db9b7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a13f9b79a63880992b1486e42976398c84feae8b
Author: Ralf Wildenhues <address@hidden>
Date:   Thu Nov 22 08:11:00 2007 +0100

    * doc/autoconf.texi (Shell Functions): New chapter.  Document
    IRIX sh $0 issue in functions, move content from ...
    (Portable Shell): ... here.
    (Shell Script Compiler): Note that shell functions are not
    totally unportable any more.

commit 844f7708855438ea616629db96544f7523c5f400
Author: Ralf Wildenhues <address@hidden>
Date:   Thu Nov 22 08:09:03 2007 +0100

    * lib/autotest/general.m4 (AT_INIT): Exit awk script after
    extracting the line numbers of the last needed test.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog               |   14 +++++++++++
 doc/autoconf.texi       |   60 +++++++++++++++++++++++++++++++++++-----------
 lib/autotest/general.m4 |    7 ++++-
 3 files changed, 65 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a689b15..efc33d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-11-22  Ralf Wildenhues  <address@hidden>
+
+       * doc/autoconf.texi (Shell Functions): New chapter.  Document
+       IRIX sh $0 issue in functions, move content from ...
+       (Portable Shell): ... here.
+       (Shell Script Compiler): Note that shell functions are not
+       totally unportable any more.
+
+2007-11-22  Stepan Kasal  <address@hidden>
+       and Ralf Wildenhues  <address@hidden>
+
+       * lib/autotest/general.m4 (AT_INIT): Exit awk script after
+       extracting the line numbers of the last needed test.
+
 2007-11-20  Ralf Wildenhues  <address@hidden>
 
        * lib/autotest/general.m4 (AT_INIT) <at_func_create_debugging_script>:
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 7f3428a..76d4b77 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -485,6 +485,7 @@ Portable Shell Programming
 * Parentheses::                 Parentheses in shell scripts
 * Slashes::                     Slashes in shell scripts
 * Special Shell Variables::     Variables you should not change
+* Shell Functions::             What to look out for if you use them
 * Limitations of Builtins::     Portable use of not so portable /bin/sh
 * Limitations of Usual Tools::  Portable use of portable tools
 
@@ -1040,6 +1041,8 @@ make it easy to write @command{configure} scripts by 
hand.  Sigh!
 Unfortunately, shell functions do not belong to the least common
 denominator; therefore, where you would like to define a function and
 use it ten times, you would instead need to copy its body ten times.
+Even in 2007, where shells without any function support are far and
+few between, there are pitfalls to avoid when making use of them.
 
 So, what is really needed is some kind of compiler, @command{autoconf},
 that takes an Autoconf program, @file{configure.ac}, and transforms it
@@ -12156,21 +12159,8 @@ to the lowest common denominator.  Even @code{unset} 
is not supported
 by all shells!
 
 Shell functions are considered portable nowadays, though Autoconf still
-does not use them (Autotest does).  However, inside a shell function,
-you should not rely on the error status of a subshell if the last
-command of that subshell was @code{exit} or @code{trap}, as this
-triggers bugs in zsh 4.x; while Autoconf tries to find a shell that
-does not exhibit the bug, zsh might be the only shell present on the
-user's machine.  Also, variables and functions may share a namespace,
-for example with Solaris 10 @command{/bin/sh}:
-
address@hidden
-$ @kbd{f () @{ :; @}; f=; f}
-f: not found
address@hidden example
-
address@hidden
-For this reason, Autotest uses the prefix @samp{at_func_} for its functions.
+does not use them (Autotest does).  However, some pitfalls have to be
+avoided for portable use of shell functions.
 
 Some ancient systems have quite
 small limits on the length of the @samp{#!} line; for instance, 32
@@ -12207,6 +12197,7 @@ subset described above, is fairly portable nowadays.  
Also please see
 * Parentheses::                 Parentheses in shell scripts
 * Slashes::                     Slashes in shell scripts
 * Special Shell Variables::     Variables you should not change
+* Shell Functions::             What to look out for if you use them
 * Limitations of Builtins::     Portable use of not so portable /bin/sh
 * Limitations of Usual Tools::  Portable use of portable tools
 @end menu
@@ -13525,6 +13516,45 @@ This variable is an alias to @samp{$?} for @code{zsh} 
(at least 3.1.6),
 hence read-only.  Do not use it.
 @end table
 
address@hidden Shell Functions
address@hidden Shell Functions
address@hidden Shell Functions
+
+Nowadays, it is difficult to find a shell that does not support
+shell functions at all.  However, some differences should be expected:
+
+Inside a shell function, you should not rely on the error status of a
+subshell if the last command of that subshell was @code{exit} or
address@hidden, as this triggers bugs in zsh 4.x; while Autoconf tries to
+find a shell that does not exhibit the bug, zsh might be the only shell
+present on the user's machine.
+
+Shell variables and functions may share the same namespace, for example
+with Solaris 10 @command{/bin/sh}:
+
address@hidden
+$ @kbd{f () @{ :; @}; f=; f}
+f: not found
address@hidden example
+
address@hidden
+For this reason, Autotest uses the prefix @samp{at_func_} for its
+functions.
+
+Handling of positional parameters and shell options varies among shells.
+For example, Korn shells reset and restore trace output (@samp{set -x})
+and other options upon function entry and exit.  Inside a function,
address@hidden sh sets @samp{$0} to the function name.
+
+Some ancient Bourne shell variants with function support did not reset
address@hidden@var{i}, @var{i} >= 0}, upon function exit, so effectively the
+arguments of the script were lost after the first function invocation.
+It is probably not worth worrying about these shells any more.
+
+With @acronym{AIX} sh, a @command{trap} on 0 installed in a shell function
+triggers at function exit rather than at script exit, see @xref{Limitations
+of Builtins}.
+
 @node Limitations of Builtins
 @section Limitations of Shell Builtins
 @cindex Shell builtins
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 8b6a34a..b40db8d 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -872,6 +872,9 @@ else
   at_diff=diff
 fi
 
+# Get the last needed group.
+for at_group in $at_groups; do :; done
+
 # Extract the start and end lines of each test group at the tail
 # of this file
 awk '
@@ -880,7 +883,9 @@ BEGIN { FS="" }
   start = NR
 }
 /address@hidden:@AT_STOP_/ {
-  print "at_sed" substr ($ 0, 10) "=\"1," start "d;" NR "q\""
+  test = substr ($ 0, 10)
+  print "at_sed" test "=\"1," start "d;" NR "q\""
+  if (test == '$at_group') exit
 }' "$at_myself" > "$at_test_source"
 . "$at_test_source"
 


hooks/post-receive
--
GNU Autoconf source repository




reply via email to

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