autoconf-patches
[Top][All Lists]
Advanced

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

PATCH: silence ash during shell search


From: Eric Blake
Subject: PATCH: silence ash during shell search
Date: Fri, 24 Dec 2004 14:15:15 -0700
User-agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)

ash (the default sh of cygwin) has the annoying habit of reporting file not found, even when stderr is redirected, if the file is nonexistant or non-executable. The only way to get rid of that message is to use test -x first, or to run in a subshell. Since not all variants of sh nicely support test -x, it is more portable to test using a subshell:

$nonexistant
nonexistant: not found
$nonexistant >/dev/null
nonexistant: not found
$nonexistant 2>/dev/null
nonexistant: not found
$(nonexistant) >/dev/null
nonexistant: not found
$(nonexistant) 2>/dev/null
$

This affects ./configure scripts on cygwin, when sh (ash) and ksh, but not bash, are installed. Configure starts out using ash because of the #! line, but prefers ksh for function support; which means a warning message appears during the test for a working bash during the shell search:

$ ./configure --version
/bin/bash: not found
GNU m4 configure 1.4q
generated by GNU Autoconf 2.59c

Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002,
2003, 2004 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
$ autoconf --version
autoconf (GNU Autoconf) 2.59c
Written by David J. MacKenzie and Akim Demaille.

Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$

The attached patch to CVS head will silence ash and any other noisy /bin/sh variant. You may also want to update the shell limitation documentation to mention this limitation of ash.

2004-12-24  Eric Blake  <address@hidden>

        * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Test candidate
        shells in subshell, to avoid noise from ash.

--
Someday, I might put a cute statement here.

Eric Blake             address@hidden

Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.128
diff -u -p -r1.128 m4sh.m4
--- lib/m4sugar/m4sh.m4 21 Dec 2004 14:24:01 -0000      1.128
+++ lib/m4sugar/m4sh.m4 24 Dec 2004 21:10:46 -0000
@@ -228,7 +228,8 @@ if test "x$CONFIG_SHELL" = x; then
        esac])
 
       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])],
               [CONFIG_SHELL=$as_shell
               as_have_required=yes
               AS_IF([_AS_RUN([_AS_DETECT_SUGGESTED_BODY], [$as_shell 2> 
/dev/null])],

reply via email to

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