Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
13 Views

sh incompatibility in mklvars.sh

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
Highlighted
Moderator
13 Views

Thanks for letting us know.

I'll file a bug report about it.

Jennifer
0 Kudos
Highlighted
Valued Contributor I
13 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
Highlighted
Black Belt
13 Views

So, '==' is OK

Yes, but not if Zsh expects POSIX compliance or does not understand Bash extensions to sh.
0 Kudos
Highlighted
Valued Contributor I
13 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
Highlighted
Beginner
13 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