Reputation: 6152
I have the following code:
ENVIRONMENT=production
if [ "$ENVIRONMENT" != "production" -o "$ENVIRONMENT" != "staging" ]; then
echo "$ENVIRONMENT is not supported, you may use production or staging"
exit
fi
this is the output:
$ production is not supported, you may use production or staging
What am I doing wrong?
Thanks
Upvotes: 0
Views: 38
Reputation: 7297
Use case
instead it's more convenient
ENVIRONMENT=production
case "$ENVIRONMENT" in
production|staging) : ;; # : means do nothing
* ) echo "$ENVIRONMENT is not supported, you may use production or staging";;
esac
Upvotes: 1
Reputation: 241998
You need -a
instead of -o
. If $ENVIRONMENT is production
, it still isn't staging
.
Upvotes: 2