[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Success (mostly) with the testsuite
From: |
Akim Demaille |
Subject: |
Re: Success (mostly) with the testsuite |
Date: |
29 Nov 2000 18:46:26 +0100 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands) |
Alexandre wrote:
| >
| > How about:
| >
| > CONFIG_FILES=${CONFIG_FILES-$config_files}
| >
| > ?
Did you really mean a dash? As opposed to an equal.
David wrote:
|
| This proposal does work.
|
So here is my proposal. I tried to document faithfully the various
issues of assigning a default value. I tried to fix the Solaris brace
bug the libtool team faced some time ago. Alexandre, could you
confirm this is what you wanted:
/tmp % cat configure.in nostromo 18:44
AC_INIT
ac_cv_toto='${foo}'
ac_cv_tata=tata
AC_OUTPUT
/tmp % ace nostromo 18:44
/tmp % ./configure -C nostromo 18:44
creating cache config.cache
updating cache config.cache
creating ./config.status
/tmp % egrep 'toto|tata' config.cache nostromo 18:44
ac_cv_tata=${ac_cv_tata=tata}
test "${ac_cv_toto+set}" = set || ac_cv_toto='${foo}'
I'm applying the following patch, again so that David can check the
fix is effective, but modification requirements are most welcome!
Index: ChangeLog
from Akim Demaille <address@hidden>
* doc/autoconf.texi (Shell Substitutions): More on the variations
around ${foo=bar}.
(Assignments): Rewrite as a summary of the previous section.
* acgeneral.m4 (AC_CACHE_SAVE): Be protected against the Solaris'
`${foo='${bar}'}' bug.
Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.638
diff -u -u -r1.638 acgeneral.m4
--- acgeneral.m4 2000/11/29 16:08:43 1.638
+++ acgeneral.m4 2000/11/29 17:39:21
@@ -1974,7 +1974,7 @@
# Save the cache.
# Allow a site initialization script to override cache values.
m4_define([AC_CACHE_SAVE],
-[cat >confcache <<\EOF
+[cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
@@ -1988,9 +1988,14 @@
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.
-EOF
+_ACEOF
+
_AC_CACHE_DUMP() |
- sed '/^ac_cv_env/!s/^\([[^=]]*\)=\(.*\)$/\1=${\1=\2}/' >>confcache
+ sed ['
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t cleanup
+ /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ : cleanup'] >>confcache
if cmp -s $cache_file confcache; then :; else
if test -w $cache_file; then
test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
Index: doc/autoconf.texi
===================================================================
RCS file: /cvs/autoconf/doc/autoconf.texi,v
retrieving revision 1.395
diff -u -u -r1.395 autoconf.texi
--- doc/autoconf.texi 2000/11/29 15:52:02 1.395
+++ doc/autoconf.texi 2000/11/29 17:39:36
@@ -5187,8 +5187,18 @@
Old @sc{bsd} shells, including the Ultrix @code{sh}, don't accept the
colon for any shell substitution, and complain and die.
address@hidden address@hidden@var{var}='@var{value}'@}
address@hidden address@hidden@var{var}='@var{value}'@}
address@hidden address@hidden@address@hidden@}
address@hidden address@hidden@address@hidden@}
+Be sure to quote:
+
address@hidden
+: address@hidden'Some words'@}
address@hidden example
+
address@hidden
+otherwise some shells, such as on Digital Unix V 5.0, will die because
+of a ``bad substitution''.
+
Solaris' @command{/bin/sh} has a frightening bug in its understanding
this. Imagine you need set a variable to a string containing @address@hidden
This @address@hidden character got Solaris' @command{/bin/sh} confused when
@@ -5214,6 +5224,70 @@
it is enclosed in single quotes. The problem doesn't happen using
double quotes.
address@hidden address@hidden@address@hidden@}
address@hidden address@hidden@address@hidden@}
+On Ultrix,
+running
+
address@hidden
+default="yu,yaa"
+: address@hidden"$default"@}
address@hidden example
+
address@hidden
+will set @var{var} to @samp{M-yM-uM-,M-yM-aM-a}, i.e., the 8th bit of
+each char will be set. You won't observe the phenomenon using a simple
address@hidden $var} since apparently the shell resets the 8th bit when it
+expands $var. Here are two means to make this shell confess its sins:
+
address@hidden
+$ cat -v <<EOF
+$var
+EOF
address@hidden example
+
address@hidden
+and
+
address@hidden
+$ set | grep '^var=' | cat -v
address@hidden example
+
+One classical incarnation of this bug is:
+
address@hidden
+default="a b c"
+: address@hidden"$default"@}
+for c in $list; do
+ echo $c
+done
address@hidden example
+
address@hidden
+You'll get @samp{a b c} on a single line. Why? Because there are no
+spaces in @samp{$list}: there are @samp{M- }, i.e., spaces with the 8th
+bit set, hence no IFS splitting is performed!!!
+
+A good news is that Ultrix works fine with @samp{: address@hidden@}},
+i.e., if you @emph{don't} quote. A bad news is then that @sc{qnx} 4.2.5
+then sets @var{list} to the @emph{last} item of @var{default}!
+
+The portable way out consists in using a double assignment, to switch
+twice the 8th bit on Ultrix:
+
address@hidden
address@hidden"$default"@}
address@hidden example
+
address@hidden
+but beware of the @address@hidden bug from Solaris (see above). For safety,
+use
+
address@hidden
+test address@hidden@} = set || address@hidden@address@hidden
address@hidden example
+
+
@item $(@var{commands})
@cindex $(@var{commands})
This construct is meant to replace @address@hidden; they can be
@@ -5242,38 +5316,53 @@
@node Assignments, Special Shell Variables, Shell Substitutions, Portable Shell
@subsection Assignments
-A nonportable shell programming construct is
+When setting several variables in a row, be aware that the order of the
+evaluation is undefined. For instance @samp{foo=1 foo=2; echo $foo}
+gives @samp{1} with sh on Solaris, but @samp{2} with Bash. You must use
address@hidden;} to enforce the order: @samp{foo=1; foo=2; echo $foo}.
+
+To assign default values follow this algorithm:
+
address@hidden
address@hidden
+If the default value is a literal and does not contain any closing
+brace, use
+
@example
address@hidden@address@hidden:address@hidden@}
+: address@hidden'my literal'@}
@end example
address@hidden
-The intent is to set @var{var} to @var{value} only if it is not already
-set, but if @var{var} has any value, even the empty string, to leave it
-alone. Old @sc{bsd} shells, including the Ultrix @code{sh}, don't
-accept the colon for any shell substitution, and complain and die. A
-portable equivalent is
address@hidden
+If the default value contains no closing brace, has to be expanded and
+the variable being initialized will never be IFS split (i.e., it's not a
+list), then use:
@example
-: address@hidden@address@hidden@}
+: address@hidden"$default"@}
@end example
-If the value is a literal string, it should be quoted:
address@hidden
+If the default value contains no closing brace, has to be expanded and
+the variable being initialized will be IFS split (i.e., it's not a
+list), then use:
@example
-: address@hidden'Some words'@}
address@hidden"$default"@}
@end example
address@hidden
-otherwise some shells, such as on Digital Unix V 5.0, will die because
-of a ``bad substitution''.
address@hidden
+If the default value contains a closing brace, then use
-When setting several variables in a row, be aware that the order of the
-evaluation is undefined. For instance @samp{foo=1 foo=2; echo $foo}
-gives @samp{1} with sh on Solaris, but @samp{2} with Bash. You must use
address@hidden;} to enforce the order: @samp{foo=1; foo=2; echo $foo}.
address@hidden
+test "address@hidden@}" = set || var='address@hidden@}'
address@hidden example
address@hidden enumerate
+In most cases @address@hidden"$default"@}} is fine, but in case of
+doubt, just use the latter. @xref{Shell Substitutions}, items
address@hidden@address@hidden:address@hidden@}} and
@address@hidden@address@hidden@}}
+for the rationale.
@node Special Shell Variables, Limitations of Builtins, Assignments, Portable
Shell
- Re: AS_DIRNAME and expr, (continued)
- Re: AS_DIRNAME and expr, David Morgan, 2000/11/16
- Re: AS_DIRNAME and expr, Paul Berrevoets, 2000/11/17
- Re: AS_DIRNAME and expr, Akim Demaille, 2000/11/29
- Re: AS_DIRNAME and expr, Paul Eggert, 2000/11/29
- Re: AS_DIRNAME and expr, Akim Demaille, 2000/11/29
- Re: AS_DIRNAME and expr, Akim Demaille, 2000/11/29
- Re: AS_DIRNAME and expr, Paul Berrevoets, 2000/11/29
- Re: AS_DIRNAME and expr, Akim Demaille, 2000/11/29
- Re: AS_DIRNAME and expr, Akim Demaille, 2000/11/10
- Re: AS_DIRNAME and expr, Paul Eggert, 2000/11/10
Re: Success (mostly) with the testsuite,
Akim Demaille <=