Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

both [[ string1 == string2 ]] and [[ string1 = string2 ]] means equal. But some other guy told me their machine don't support ==. The error message is: syntax error: `==' unexpected.

Seems they use pretty old UNIX with korn shell and I'm using REHL5.2. Since I cannot access their machines, how do I find out which version start to support "=="?

Thanks

share|improve this question

1 Answer 1

You can look at the value of $SHELL and see if it's set to the shell's executable. You could then test and branch on the value of it, or lack thereof; I don't know if this will be set on older shells.

If you don't need the advanced features of [[ then use [ instead. This web page explains the differences in detail. Also take a look at this related question.

If you are only going to compare strings with == then use the POSIX syntax for the greatest compatibility: [ string1 = string2 ] which uses a single equals sign.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.