I have a script similar following one:
#!/usr/bin/sh
var="ABC"
if [ $var == "ABC" ]
then
echo True
else
echo False
fi
Above code does not work in Solaris Sparc and Solaris X64. It is showing ==
undefined.
Above code works fine If I replace ==
with =
.
Strange thing is If I ran above code without any change by following method it is working.
#bash test.sh
According to my understanding the script should not work even with bash, as at the top of the script I am using #!/bin/sh
which does not support the ==
as the comparison operator.
Can anyone please explain why it does work when I am running the script as mentioned above.
Note: I am aware of that bash does recognize ==
and =
.