[PATCH 1/4] Make configure use /bin/bash instead of /bin/sh

Tomi Ollila tomi.ollila at iki.fi
Wed Apr 11 11:47:32 PDT 2012


On Wed, Apr 11 2012, Vladimir Marek <Vladimir.Marek at Oracle.COM> wrote:

> Hi,
>

[ ... ]

>
>> Does the configure script work if you replace /bin/sh with /bin/ksh
>> in your Solaris box
>
> yes, it does work if executed by /bin/bash or /bin/ksh
>
>
>> If yes, something like the following could be added to the beginning
>> of 'configure'
>> 
>> option=option=value
>> if test ! x"${option$*=}" = x"value" 2>/dev/null; then
>> 	if test x"${PREVENT_LOOPING-}" = x; then
>>         	PREVENT_LOOPING=true; export PREVENT_LOOPING
>>                 test ! -x /bin/ksh || exec /bin/ksh "$0" "$@"
>>                 test ! -x /bin/bash || exec /bin/bash "$0" "$@"
>>         fi
>>         echo "Cannot find compatible shell for '$0'" >&2
>>         exit 1
>> fi
>
> Unfortunately, no. The /bin/sh says "bad substitution" and does not run
> the script at all. I also tried
>
> eval 'echo ${A%%1}'; echo ok
>
> but that does not run the 'echo ok' and fails also.

You're right! I tested this stuff using heirloom-sh
from http://heirloom.sourceforge.net/sh.html

It is interesting that the shell stops executing when 
it finds this syntax (instead of contnuing, even without -e)

> I can see three possible solutions
>
> 1) use bash or ksh in the shebang line

Cannot do there are systems lacking /bin/bash & /bin/ksh

> 2) rewrite the script as I gave the overview

Some work todo; case construct can do option key matching to get 
identical interface and then cut or sed to get just option value.

> 3) declare that solaris 10 /bin/sh is not compatible with configure
> script
>
> Frankly even 3) is viable option, one just have to remember to run
> 'bash configure'. If everything else would work, I would be happy :)

Option 4) use the following heuristics:

case ~ in '~')
	if test x"${PREVENT_LOOPING-}" = x; then
		PREVENT_LOOPING=true; export PREVENT_LOOPING
		for x in /bin/ksh /bin/bash /usr/bin/bash
		do test ! -x "$x" || exec "$x" "$0" "$@"
                done
	fi
	echo "Cannot find compatible shell for '$0'" >&2
	exit 1
esac

i.e. if tilde expansion is not done guess this shell is not 
compatible enough

Option 5) do substitution check in subshell:

( option=option=value; : ${option$*=} ) 2>/dev/null || {
	if test x"${PREVENT_LOOPING-}" = x; then
		PREVENT_LOOPING=true; export PREVENT_LOOPING
		for x in /bin/ksh /bin/bash /usr/bin/bash
		do test ! -x "$x" || exec "$x" "$0" "$@"
                done
	fi
	echo "Cannot find compatible shell for '$0'" >&2
	exit 1
}

>
> Thank you
> -- 
> 	Vlad

Tomi


More information about the notmuch mailing list