Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

sh incompatibility in mklvars.sh

Matthias_Kretz
New Contributor I
492 Views
Hi,

the mklvars.sh script shipped with the Linux edition of the Intel compiler fails to work on zsh because it is sh incompatible: The use of [ "" == "" ] is incorrect and instead [ "" = "" ] must be used.

I had to patch that script to be able to use the environment script provided by the package.

Cheers,
Matthias
0 Kudos
5 Replies
JenniferJ
Moderator
492 Views
Thanks for letting us know.

I'll file a bug report about it.

Jennifer
0 Kudos
barragan_villanueva_
Valued Contributor I
492 Views
Hi,

According to man sh

CONDITIONAL EXPRESSIONS

Conditional expressions are used by the [[ compound command and the test and [ builtin commands to test file attributes and perform

string and arithmetic comparisons.

string1 == string2

True if the strings are equal. = may be used in place of == for strict POSIX compliance.

So, '==' is OK

0 Kudos
mecej4
Honored Contributor III
492 Views
So, '==' is OK

Yes, but not if Zsh expects POSIX compliance or does not understand Bash extensions to sh.
0 Kudos
barragan_villanueva_
Valued Contributor I
492 Views
Looking at "info Zsh" (Conditional Expressions) (zsh 4.2.6)

STRING = PATTERN
STRING == PATTERN
true if STRING matches PATTERN. The `==' form is the preferred
one. The `=' form is for backward compatibility and should be
considered obsolete.

Therefore, Zsh must workas sh and bash
0 Kudos
dschwen
Beginner
492 Views
Zsh needs the == to be escaped (\=\=), which bash accepts but not sh.
There obviously is a problem for several users here, which has an easy solution: respecting POSIX compliance.
The single = works as expected in all three shells.
0 Kudos
Reply