Denys,
Here is an explanation of the reason for the problem I encountered in
solaris. The explanation comes from the admins of our department
(Marie-France Declerfayt and Freddy Gridelet). I translated in English
the few words present.
Valentin
The small script below works perfectly:
**********
#! /bin/sh
for VAL in 1 2 3 4 5 6 7 ; do
if test $VAL -lt 2; then
echo plus petit
elif
test $VAL -lt 4;then
echo plus grand
fi
done
*********
This one gives 'test: unknown operator lt' :
*********
#! /bin/sh
IFS="xxx._-"
for VAL in 1 2 3 4 5 6 7 ; do
if test $VAL -lt 2; then
echo plus petit
elif
test $VAL -lt 4;then
echo plus grand
fi
done
*********
man sh tells us :
*********
IFS Internal field separators, normally space, tab, and
newline (see Blank Interpretation section).
Blank Interpretation
After parameter and command substitution, the results of
substitution are scanned for internal field separator char-
acters (those found in IFS) and split into distinct argu-
ments where such characters are found. Explicit null argu-
ments ("" or '') are retained. Implicit null arguments
(those resulting from parameters that have no values) are
removed.
*********
Putting a character '-' in a IFS is not really recommended! If
necessary, one has to insert quotes in order to protect the normal '-'.
Question: on Linux, are there other rules (the second script works
correctly on Linux too)?
Denys Duchier wrote:
>
> valentin@info.ucl.ac.be (Valentin Mesaros) writes:
>
> > I saw that you force the shell to sh.
>
> actually, we don't do that. it is done by autoconf. but indeed, if
> your /bin/sh is a broken shell then there is a problem. I can't think
> off hand of a work around. maybe something will occur to me later.
>
> could you try to invoke /bin/sh interactively and see what kind of
> test you get with it.
>
> > How can I check that I have the right path except by running 'which
> > test' in the corresponding shell?
>
> yes, which test will work unless test is built into the shell in which
> case the shell might not tell you that. you should run a few trials by
> hand to see how your test behaves in /bin/sh.
>
> if absolutely nothing else works. Here is a one-liner that edits all
> configure files and replaces /bin/sh by /usr/local/bin/bash (use
> whatever is needed for you).
>
> perl -n -i -e 'if (m|^#! /bin/sh|) { print "#! /usr/local/bin/bash\n"; } else { print; }' -- `find . -name configure -print`
>
> Cheers,
>
> --
> Dr. Denys Duchier
> Iquipe Calligramme
> LORIA, Nancy, FRANCE
> -
> Please send submissions to hackers@mozart-oz.org
> and administriva mail to hackers-request@mozart-oz.org.
> The Mozart Oz web site is at http://www.mozart-oz.org/.
-
Please send submissions to hackers@mozart-oz.org
and administriva mail to hackers-request@mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.