[Top][All Lists]

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

Re: ./configure problems

From: Eric Sunshine
Subject: Re: ./configure problems
Date: Thu, 20 May 2004 05:39:51 -0400

On Wed, 05 May 2004 10:32:04 -0700, Paul Eggert wrote:
> Eric Sunshine <address@hidden> writes:
> > I suppose it would require only a fairly minor change to _AS_RUN()
> > to have it load the shell code from a file rather than standard
> > input. I could submit a patch if it seems worthwhile(?).
> It sounds like an easy patch, and if so could you please submit it?

The included patch augments _AS_RUN so that it invokes the test from an  
external file rather than via the shell's standard input.

-- ES

2004-05-20  Eric Sunshine  <address@hidden>

        * m4sh.m4 (_AS_RUN): Run test code from external file rather than via
        shell's standard input in order to force non-interactive mode for csh
        shells.  This resolves a near-pathalogical, yet real-world case where
        the shell test was fooled into thinking csh (or derivative) was a valid
        Bourne shell since some users 'exec /bin/sh' (or similar) at the end of
        .cshrc (or .tcshrc) when csh is run interactively.  Relevant threads:
        (AS_DETECT_REQUIRED): Do not invoke _AS_RUN for non-existent shells.
        (_AS_SHELL_FN_WORK): Use "test -eq" to check numeric result, rather
        than "test =".  Correct botched diagnostic messages for failure of
        func_success() and func_failure() functions.

--- /Users/sunshine/m4sh.m4-cvs Thu May 20 04:43:39 2004
+++ lib/m4sugar/m4sh.m4 Thu May 20 05:13:02 2004
@@ -168,18 +168,38 @@

-# ----------------------
+# ----------------------------------
 # Run TEST under the current shell (if one parameter is used)
 # or under the given SHELL, protecting it from syntax errors.
+# Disposal of output and error messages from TEST is controlled by
+# REDIRECT, which should consists of shell redirects. If not provided,
+# then output and error messages are allowed to escape to stdout & stderr.
+# We need to take special care if SHELL is csh or compatible.  This might
+# happen, for instance, when _AS_DETECT_BETTER_SHELL attempts $SHELL as a last
+# resort.  There is a near-pathalogical, yet real-world case where a user might
+# 'exec' a different shell, such as /bin/sh or /bin/zsh, at the end of .cshrc
+# (or .tcshrc) if csh is run in interactive mode.  The "exec /bin/sh" will fool
+# Autoconf into thinking that it is running a Bourne-like shell when it applies
+# TEST despite the fact that the shell is actually a C-shell or derivative.  To
+# avoid this case, we must ensure that the shell is run in non-interactive
+# mode.  This is accomplished by feeding TEST to SHELL via a file (which forces
+# non-interactive mode), rather than via SHELL's standard input (which places
+# csh in the unwanted interactive mode).
-[{ $2 <<\_ASEOF
+[{ rm -f conf$$.sh
+cat >conf$$.sh <<\_ASEOF
+$2 conf$$.sh
+rm -f conf$$.sh
+test $as_shellcode -eq 0
-[(eval "AS_ESCAPE(m4_quote($1))")])])
+[(eval "AS_ESCAPE(m4_quote($1))")]) m4_default([$3],[])])

 # ------------------------
@@ -209,26 +229,27 @@
 [m4_wrap([m4_divert_text([M4SH-SANITIZE], [
 if test "x$CONFIG_SHELL" = x; then
-  AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY]) 2>/dev/null],
+  AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY], [], [2>/dev/null 1>&2])],
   AS_IF([test $as_have_required = yes && dnl
-        _AS_RUN([_AS_DETECT_SUGGESTED_BODY]) 2> /dev/null],
+        _AS_RUN([_AS_DETECT_SUGGESTED_BODY], [], [2>/dev/null 1>&2])],
       [case $as_dir in
           for as_base in sh bash ksh sh5; do
-            as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+            AS_IF([test -f $as_dir/$as_base],
+              [as_candidate_shells="$as_candidate_shells $as_dir/$as_base"])

       for as_shell in $as_candidate_shells $SHELL; do
-        AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY], [$as_shell 2> /dev/null])],
+        AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY], [$as_shell],  
[2>/dev/null 1>&2])],
-              AS_IF([_AS_RUN([_AS_DETECT_SUGGESTED_BODY], [$as_shell 2>  
+              AS_IF([_AS_RUN([_AS_DETECT_SUGGESTED_BODY], [$as_shell],  
[2>/dev/null 1>&2])],

@@ -251,8 +272,7 @@

 # -----------------
-# This is a spy to detect "in the wild" shells that do not support shell
-# functions correctly.  It is based on the Autotest testcases.
+# Detect if the shell supports functions.
 [func_return () {
   (exit [$]1)
@@ -273,17 +293,17 @@
 AS_IF([func_success], [],
-  echo func_failure succeeded.])
+  echo func_success failed.])
-  echo func_success failed.])
+  echo func_failure succeeded.])
 AS_IF([func_ret_success], [],
   echo func_ret_success failed.])
   echo func_ret_failure succeeded.])
-test $exitcode = 0])
+test $exitcode -eq 0])

@@ -1250,7 +1270,7 @@
   echo No shell found that supports shell functions.
   echo Please tell address@hidden about your system,
-  echo including any error possibly output before this
+  echo possibly including any errors emitted before this
   echo message

reply via email to

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