autoconf-patches
[Top][All Lists]
Advanced

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

Re: about the ! builtin


From: Paul Eggert
Subject: Re: about the ! builtin
Date: Mon, 24 May 2004 12:00:22 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Alexandre Duret-Lutz <address@hidden> writes:

>      You can't use `!'; you'll have to rewrite your code.
>
> Would had been nice to document why.  Where does it not work?

Solaris 9 /bin/sh is one example.  I installed the following patch to
help clarify the situation.  This patch also cleans up the Unix
terminology, which was all over the map.

2004-05-24  Paul Eggert  <address@hidden>

        * doc/autoconf.texi (Systemology): Standardize on the spelling of
        "Unix".  Many uses changed.
        (Limitations of Builtins): Explain better why the ! command isn't
        portable.

Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.814
diff -p -u -r1.814 autoconf.texi
--- doc/autoconf.texi   17 May 2004 05:01:45 -0000      1.814
+++ doc/autoconf.texi   24 May 2004 18:56:29 -0000
@@ -342,7 +342,7 @@ Existing Tests
 * Types::                       Types that might be missing
 * Compilers and Preprocessors::  Checking for compiling programs
 * System Services::             Operating system services
-* UNIX Variants::               Special kludges for specific UNIX variants
+* Unix Variants::               Special kludges for specific Unix variants
 
 Common Behavior
 
@@ -603,7 +603,7 @@ shouted: ``And the Chaos, where do you t
 
 Autoconf is a tool for producing shell scripts that automatically
 configure software source code packages to adapt to many kinds of
address@hidden systems.  The configuration scripts produced by Autoconf
+Unix-like systems.  The configuration scripts produced by Autoconf
 are independent of Autoconf when they are run, so their users do not
 need to have Autoconf.
 
@@ -614,9 +614,9 @@ presence of each feature that the softwa
 (Before each check, they print a one-line message stating what they are
 checking for, so the user doesn't get too bored while waiting for the
 script to finish.)  As a result, they deal well with systems that are
-hybrids or customized from the more common @sc{unix} variants.  There is
+hybrids or customized from the more common Unix variants.  There is
 no need to maintain files that list the features supported by each
-release of each variant of @sc{unix}.
+release of each variant of Unix.
 
 For each software package that Autoconf is used with, it creates a
 configuration script from a template file that lists the system features
@@ -646,7 +646,7 @@ Autoconf imposes some restrictions on th
 @code{#if} in C programs (@pxref{Preprocessor Symbol Index}).
 
 Autoconf requires @acronym{GNU} M4 in order to generate the scripts.  It uses
-features that some @sc{unix} versions of M4, including @acronym{GNU} M4 1.3,
+features that some Unix versions of M4, including @acronym{GNU} M4 1.3,
 do not have.  You must use version 1.4 or later of @acronym{GNU} M4.
 
 @xref{Autoconf 1}, for information about upgrading from version 1.
@@ -3080,7 +3080,7 @@ Symbols}, for how to get those symbol de
 * Types::                       Types that might be missing
 * Compilers and Preprocessors::  Checking for compiling programs
 * System Services::             Operating system services
-* UNIX Variants::               Special kludges for specific UNIX variants
+* Unix Variants::               Special kludges for specific Unix variants
 @end menu
 
 @node Common Behavior
@@ -4030,7 +4030,7 @@ program.
 @c @fuindex getmntent
 @prindex @code{getmntent}
 Check for @code{getmntent} in the @file{sun}, @file{seq}, and @file{gen}
-libraries, for @sc{irix} 4, PTX, and Unixware, respectively.  Then, if
+libraries, for @sc{irix} 4, PTX, and UnixWare, respectively.  Then, if
 @code{getmntent} is available, define @code{HAVE_GETMNTENT}.
 @end defmac
 
@@ -4283,7 +4283,7 @@ the buffer argument.
 @cvindex HAVE_STRFTIME
 @c @fuindex strftime
 @prindex @code{strftime}
-Check for @code{strftime} in the @file{intl} library, for SCO @sc{unix}.
+Check for @code{strftime} in the @file{intl} library, for SCO Unix.
 Then, if @code{strftime} is available, define @code{HAVE_STRFTIME}.
 @end defmac
 
@@ -6207,8 +6207,8 @@ system.  If so, set the shell variable @
 @samp{yes}.  If not, set the variable to @samp{no}.
 @end defmac
 
address@hidden UNIX Variants
address@hidden UNIX Variants
address@hidden Unix Variants
address@hidden Unix Variants
 
 The following macros check for certain operating systems that need
 special treatment for some programs, due to exceptional oddities in
@@ -6842,7 +6842,7 @@ documentation.  It may help you addressi
 by users.
 
 The @href{http://bhami.com/rosetta.html, Rosetta Stone for Unix}
-contains a lot of interesting crossed information on various Unices.
+contains a lot of interesting crossed information on various Unix variants.
 
 @table @asis
 @item Darwin
@@ -6881,8 +6881,12 @@ formats.
 @item Unix version 7
 @cindex Unix version 7
 @cindex V7
+Officially this was called the ``Seventh Edition'' of ``the @sc{unix}
+time-sharing system'' but we use the more-common name ``Unix version 7''.
 Documentation is available in the
 @href{http://plan9.bell-labs.com/7thEdMan/index.html, V7 Manual}.
+Previous versions of Unix are called ``Unix version 6'', etc., but
+they were not as widely used.
 @end table
 
 
@@ -6890,7 +6894,7 @@ Documentation is available in the
 @section Multiple Cases
 
 Some operations are accomplished in several possible ways, depending on
-the @sc{unix} variant.  Checking for them essentially requires a ``case
+the Unix variant.  Checking for them essentially requires a ``case
 statement''.  Autoconf does not directly provide one; however, it is
 easy to simulate by using a shell variable to keep track of whether a
 way to perform the operation has been found yet.
@@ -8750,7 +8754,7 @@ Declarations of C variables in header fi
 @item FUNC
 Functions in libraries.
 @item GROUP
address@hidden group owners of files.
+Unix group owners of files.
 @item HEADER
 Header files.
 @item LIB
@@ -9231,7 +9235,7 @@ When writing your own checks, there are 
 techniques you should avoid in order to make your code portable.  The
 Bourne shell and upward-compatible shells like the Korn shell and Bash
 have evolved over the years, but to prevent trouble, do not take
-advantage of features that were added after @sc{unix} version 7, circa
+advantage of features that were added after Unix version 7, circa
 1977 (@pxref{Systemology}).
 
 You should not use shell functions, aliases, negated character
@@ -9623,7 +9627,7 @@ identifies problems that exist even unde
 important thing to remember when building a portable configure script,
 as @command{autoconf} uses a .in suffix for template files.
 
-This is perfectly OK on Unices:
+This is perfectly OK on Unix variants:
 
 @example
 AC_CONFIG_HEADERS([config.h])
@@ -9716,7 +9720,7 @@ strings inside double-quoted back-quoted
 One of the most famous shell-portability issues is related to
 @samp{"$@@"}.  When there are no positional arguments, @acronym{POSIX} says
 that @samp{"$@@"} is supposed to be equivalent to nothing, but the
-original Unix Version 7 Bourne shell treated it as equivalent to
+original Unix version 7 Bourne shell treated it as equivalent to
 @samp{""} instead, and this behavior survives in later implementations
 like Digital Unix 5.0.
 
@@ -10348,7 +10352,23 @@ directory, you must use @samp{. ./foo}.
 
 @item @command{!}
 @prindex @command{!}
-You can't use @command{!}; you'll have to rewrite your code.
+The Unix version 7 shell did not support
+negating the exit status of commands with @command{!}, and this feature
+is still absent from more modern shells (e.g., Solaris 9 @command{/bin/sh}).
+Shell code like this:
+
address@hidden
+if ! cmp file1 file2 >/dev/null 2>&1; then
+  echo files differ or trouble
+fi
address@hidden example
+
+is therefore not portable in practice.  Typically it is easy to rewrite
+such code, e.g.:
+
address@hidden
+cmp file1 file2 >/dev/null 2>&1 || echo files differ or trouble
address@hidden example
 
 
 @item @command{break}
@@ -10396,7 +10416,7 @@ bash-2.02$
 
 @noindent
 This is extremely unfortunate, since you are likely to use this code to
-handle @sc{unix} or @sc{ms-dos} absolute paths.  To work around this
+handle Unix or @sc{ms-dos} absolute paths.  To work around this
 bug, always put the backslash first:
 
 @example
@@ -10497,7 +10517,7 @@ received by the shell when it is launche
 variable marked as exported.
 
 Alas, many shells, such as Solaris 2.5, @sc{irix} 6.3, @sc{irix} 5.2,
address@hidden 4.1.5, and Digital @sc{unix} 4.0, forget to
address@hidden 4.1.5, and Digital Unix 4.0, forget to
 @command{export} the environment variables they receive.  As a result,
 two variables coexist: the environment variable and the shell
 variable.  The following code demonstrates this failure:
@@ -10970,7 +10990,7 @@ lack support for it.  @xref{C Compiler},
 tests for this feature with @code{AC_PROG_CC_C_O}.
 
 When a compilation such as @samp{cc -o foo foo.c} fails, some compilers
-(such as @sc{cds} on Reliant @sc{unix}) leave a @file{foo.o}.
+(such as @sc{cds} on Reliant Unix) leave a @file{foo.o}.
 
 HP-UX @command{cc} doesn't accept @file{.S} files to preprocess and
 assemble.  @samp{cc -c foo.S} will appear to succeed, but in fact does
@@ -11175,9 +11195,9 @@ expr '' \| ''
 @end example
 
 @acronym{GNU}/Linux and @acronym{POSIX}.2-1992 return the empty string
-for this case, but traditional @sc{unix} returns @samp{0} (Solaris is
+for this case, but traditional Unix returns @samp{0} (Solaris is
 one such example).  In @acronym{POSIX}.1-2001, the specification has
-been changed to match traditional @sc{unix}'s behavior (which is
+been changed to match traditional Unix's behavior (which is
 bizarre, but it's too late to fix this).  Please note that the same
 problem does arise when the empty string results from a computation,
 as in:
@@ -11331,7 +11351,7 @@ The portable options are @option{-acdilr
 @c
 @c # telnet dim
 @c [...]
address@hidden   UNIX System V (TWG-TCP/IP) (dim.blilly.com)
address@hidden   Unix System V (TWG-TCP/IP) (dim.blilly.com)
 @c [...]
 @c $ mkdir foo
 @c $ cd foo
@@ -11341,7 +11361,7 @@ The portable options are @option{-acdilr
 @c /bin/ls:
 @c           fndcmd:fndcmd.sl 1.68
 @c $ uname -a
address@hidden UNIX dim SYSTEM5 3.51m mc68k
address@hidden Unix dim SYSTEM5 3.51m mc68k
 @c
 @c It's an AT&T 3B1.  See http://www.faqs.org/faqs/3b1-faq/ or any
 @c mirror of the 3B1 FAQ.  It's actually SVR2.2.
@@ -11387,7 +11407,8 @@ older versions are not thread-safe eithe
 @cindex Moving open files
 The only portable options are @option{-f} and @option{-i}.
 
-Moving individual files between file systems is portable (it was in V6),
+Moving individual files between file systems is portable (it was in Unix
+version 6),
 but it is not always atomic: when doing @samp{mv new existing}, there's
 a critical section where neither the old nor the new version of
 @file{existing} actually exists.
@@ -11487,7 +11508,8 @@ sed @var{instruction-1};@var{instruction
 
 Contrary to yet another urban legend, you may portably use @samp{&} in
 the replacement part of the @code{s} command to mean ``what was
-matched''.  All descendants of Bell Lab's V7 @command{sed} (at least; we
+matched''.  All descendants of Bell Lab's Unix version 7 @command{sed}
+(at least; we
 don't have first hand experience with older @command{sed}s) have
 supported it.
 
@@ -13775,7 +13797,7 @@ Use @samp{AC_CHECK_SIZEOF(int)} instead.
 
 @defmac AC_IRIX_SUN
 @acindex{IRIX_SUN}
-If on @sc{irix} (Silicon Graphics @sc{unix}), add @option{-lsun} to output
+If on @sc{irix} (Silicon Graphics Unix), add @option{-lsun} to output
 @code{LIBS}.  If you were using it to get @code{getmntent}, use
 @code{AC_FUNC_GETMNTENT} instead.  If you used it for the NIS versions
 of the password and group functions, use @samp{AC_CHECK_LIB(sun,
@@ -14050,7 +14072,7 @@ removed because of limited usefulness
 @defmac AC_SCO_INTL
 @acindex{SCO_INTL}
 @ovindex LIBS
-If on SCO UNIX, add @option{-lintl} to output variable @code{LIBS}.  This
+If on SCO Unix, add @option{-lintl} to output variable @code{LIBS}.  This
 macro used to
 
 @example
@@ -15086,7 +15108,7 @@ need, but therefore most of the time it 
 @table @asis
 @item command line arguments
 @c akim s/to consist in/to consist of/
-A very bad Unix habit which is unfortunately wide spread consists of
+A very bad Unix habit which is unfortunately widespread consists of
 setting environment variables before the command, such as in
 @samp{CC=my-home-grown-cc ./testsuite}.  This results in the test suite
 not knowing this change, hence (i) it can't report it to you, and (ii)
@@ -15935,7 +15957,7 @@ out a new language.
 Since my @command{configure} scripts determine the system's capabilities
 automatically, with no interactive user intervention, I decided to call
 the program that generates them Autoconfig.  But with a version number
-tacked on, that name would be too long for old @sc{unix} file systems,
+tacked on, that name would be too long for old Unix file systems,
 so I shortened it to Autoconf.
 
 In the fall of 1991 I called together a group of fellow questers after
@@ -15968,7 +15990,7 @@ Autoconf continued to improve rapidly, a
 @command{configure} scripts reported problems they encountered.
 
 Autoconf turned out to be a good torture test for M4 implementations.
address@hidden M4 started to dump core because of the length of the
+Unix M4 started to dump core because of the length of the
 macros that Autoconf defined, and several bugs showed up in @acronym{GNU}
 M4 as well.  Eventually, we realized that we needed to use some
 features that only @acronym{GNU} M4 has.  address@hidden M4, in




reply via email to

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