I have a shell script like this,
#! /bin/sh
if [ -z "$ENVIRON" ]; then
echo "no env set"
elif [ "$ENVIRON" == "test" ]; then
echo "test mode"
else
echo "production mode"
fi
when I run this im getting error,
[: test: unexpected operator
I also tried changing to elif [ $ENVIRON == "test" ]; then
, but getting the same error. When I run this on my mac I get the expected result:
tw tmp $ cat script.sh
#! /bin/sh
if [ -z "$ENVIRON" ]; then
echo "no env set"
elif [ "$ENVIRON" == "test" ]; then
echo "test mode"
else
echo "production mode"
fi
tw tmp $ ENVIRON=test sh script.sh
test mode
But getting error while running the exact same script in ubuntu
What am I doing wrong and how to fix this?