On Wed, 06 Dec 2006 10:03:11 +0100, Otto Moerbeek wrote: >> # if [ "-n" == "foo" -o "$demo" == "-e" ]; then >> > echo bar >> > fi >> ksh: [: foo: unexpected operator/operand but still, it doesn't. Even > > Yes it is strange these are not accepted while the expression below is.
> These are all borderline cases. Follow recommended shell programming > practises to avoid these. Portability of *existing* software ? These examples are handled properly (bash-bash) by "just another" shell. I guess, counting arguments is a good helper, though I haven't looked into the code. > This is the list of precedence for arithmetic expressions, which are not > the same as the expressions handled by [ .. ] . This is what I understand. Where do I find the precedences for relational operators ? If they are different, by the way. What we see here, is that OR has a higher precedence than ==. Life is full of surprises, though. If someone shows that the behaviour of bash in *one of these examples* clearly violates basic programming and shell practice, I'll shut up immediately. Okay I shut up in any case w.r.t. this thread. Thanks to anyone who tried to help out with their respective knowledge ! Uwe