* [PATCH] configure: test shell parameter substring processing and possibly exec one
@ 2012-04-16 15:13 Tomi Ollila
2012-04-17 6:14 ` Tomi Ollila
2012-05-03 18:59 ` [PATCH] configure: check whether shell is capable of parameter substring processing Tomi Ollila
0 siblings, 2 replies; 5+ messages in thread
From: Tomi Ollila @ 2012-04-16 15:13 UTC (permalink / raw)
To: notmuch; +Cc: Tomi Ollila
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] configure: test shell parameter substring processing and possibly exec one
2012-04-16 15:13 [PATCH] configure: test shell parameter substring processing and possibly exec one Tomi Ollila
@ 2012-04-17 6:14 ` Tomi Ollila
2012-05-02 22:25 ` David Bremner
2012-05-03 18:59 ` [PATCH] configure: check whether shell is capable of parameter substring processing Tomi Ollila
1 sibling, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2012-04-17 6:14 UTC (permalink / raw)
To: notmuch; +Cc: Tomi Ollila
'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 on 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
addition of 'set -eu' in the beginning of this script.
---
This patch obsoleted id:"1334589199-25894-1-git-send-email-tomi.ollila@iki.fi"
diff:
-+ NOTMUCH_CONFIGURE=1; export _NOTMUCH_CONFIGURE
++ _NOTMUCH_CONFIGURE=1; export _NOTMUCH_CONFIGURE
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,6 +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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] configure: test shell parameter substring processing and possibly exec one
2012-04-17 6:14 ` Tomi Ollila
@ 2012-05-02 22:25 ` David Bremner
0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2012-05-02 22:25 UTC (permalink / raw)
To: Tomi Ollila, notmuch
I'm still a bit leery of over-complicating the configure script to
support legacy /bin/sh; however, I guess I'm at least convinced that the
only trivial solution is just to document the requirement for posix
/bin/sh. It will be odd to back this out and document the restriction
later, so please chime in now if you have strong feelings either way.
Tomi Ollila <tomi.ollila@iki.fi> writes:
> 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.
s/attemts/attempts/
> 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
> addition of 'set -eu' in the beginning of this script.
OK, although I might have gone for the empty if myself.
> +# If not, attempt to locate and launch one which probably can.
> +( option=option=value; : ${option#*=} ) 2>/dev/null || {
option=option=value seems a little _too_ clever to me. Any reason not to
use e.g.
option="A,B"
> + if test x"${_NOTMUCH_CONFIGURE-}" = x ; then
> + _NOTMUCH_CONFIGURE=1; export _NOTMUCH_CONFIGURE
This could probably use a comment.
> + for x in /bin/ksh /bin/bash /usr/bin/bash
I guess add /usr/local/bin/bash? I'm slightly worried this list will
just keep growing.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] configure: check whether shell is capable of parameter substring processing
2012-04-16 15:13 [PATCH] configure: test shell parameter substring processing and possibly exec one Tomi Ollila
2012-04-17 6:14 ` Tomi Ollila
@ 2012-05-03 18:59 ` Tomi Ollila
2012-07-25 11:21 ` David Bremner
1 sibling, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2012-05-03 18:59 UTC (permalink / raw)
To: notmuch; +Cc: Tomi Ollila
'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 on 1990's systems).
Just testing whether parameter substring processing works will make the
shell exit due to syntax error if it is not compatible. Therefore the test
is executed in a subshell -- subshell exits with nonzero value when the
operation in question fails.
As 'if ! ...' does not work in Bourne shell, Short-circuiting construct
'||' is used to print information message and exit when expected.
---
This is now based on last short talk on IRC. Anyone good with words
care to comment on text content ? :)
This patch obsoletes:
id:"1334643263-30207-1-git-send-email-tomi.ollila@iki.fi" ,
id:"1334589199-25894-1-git-send-email-tomi.ollila@iki.fi"
and
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..7a13102 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,19 @@
#! /bin/sh
+# Test whether this shell is capable of parameter substring processing.
+( option='a/b'; : ${option#*/} ) 2>/dev/null || {
+ echo "
+The shell interpreting '$0' is lacking some required features.
+
+To work around this problem you may try to execute:
+
+ ksh $0 $*
+ or
+ bash $0 $*
+"
+ exit 1
+}
+
# Store original IFS value so it can be changed (and restored) in many places.
readonly DEFAULT_IFS=$IFS
--
1.7.8.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] configure: check whether shell is capable of parameter substring processing
2012-05-03 18:59 ` [PATCH] configure: check whether shell is capable of parameter substring processing Tomi Ollila
@ 2012-07-25 11:21 ` David Bremner
0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2012-07-25 11:21 UTC (permalink / raw)
To: Tomi Ollila, notmuch
Tomi Ollila <tomi.ollila@iki.fi> writes:
> '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 on 1990's systems).
pushed, finally.
d
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-07-25 11:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-16 15:13 [PATCH] configure: test shell parameter substring processing and possibly exec one Tomi Ollila
2012-04-17 6:14 ` Tomi Ollila
2012-05-02 22:25 ` David Bremner
2012-05-03 18:59 ` [PATCH] configure: check whether shell is capable of parameter substring processing Tomi Ollila
2012-07-25 11:21 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).