Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id A5B0F431FAF for ; Mon, 16 Apr 2012 08:13:28 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RcbzVNATEMdz for ; Mon, 16 Apr 2012 08:13:28 -0700 (PDT) Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66]) by olra.theworths.org (Postfix) with ESMTP id D8611431FAE for ; Mon, 16 Apr 2012 08:13:27 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id 6445768055; Mon, 16 Apr 2012 18:13:21 +0300 (EEST) From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH] configure: test shell parameter substring processing and possibly exec one Date: Mon, 16 Apr 2012 18:13:19 +0300 Message-Id: <1334589199-25894-1-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 1.7.6.1 Cc: Tomi Ollila X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2012 15:13:28 -0000 configure script uses parameter substring extensively. It is Posix shell feature. Original Bourne shell does not have such features. Some systems still ships such shells as /bin/sh (for compatibility reasons -- shell scripts written on those platforms are expected to work in 1990's systems...) To tackle this situation the beginning of configure attemts to do a silent parameter substitution in a subshell; in case this fails the subshell exits with nonzero value which is easy to detect. The || constructs are used twice. The first one is used as Bourne shell chokes on 'if ! ... ' construct (and if ...; then :; else do_things; fi looks stupid). The second one(liner) takes care of the possible future 'set -eu' in the beginning of this script. --- This patch obsoletes id:"1333966665-10469-2-git-send-email-Vladimir.Marek@oracle.com" configure | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/configure b/configure index 71981b7..06fbeff 100755 --- a/configure +++ b/configure @@ -1,5 +1,19 @@ #! /bin/sh +# Test whether this sh is capable of parameter substring processing. +# If not, attempt to locate and launch one which probably can. +( option=option=value; : ${option#*=} ) 2>/dev/null || { + if test x"${_NOTMUCH_CONFIGURE-}" = x ; then + NOTMUCH_CONFIGURE=1; export _NOTMUCH_CONFIGURE + for x in /bin/ksh /bin/bash /usr/bin/bash + do test ! -x "$x" || exec "$x" "$0" "$@" + done + fi + echo "Cannot find compatible shell to execute '$0'" >&2 + exit 1 +} +unset _NOTMUCH_CONFIGURE + # Store original IFS value so it can be changed (and restored) in many places. readonly DEFAULT_IFS=$IFS -- 1.7.8.2