I tried to check if the PHONE_TYPE
variable contains one of three valid values.
if [ "$PHONE_TYPE" != "NORTEL" ] || [ "$PHONE_TYPE" != "NEC" ] ||
[ "$PHONE_TYPE" != "CISCO" ]
then
echo "Phone type must be nortel,cisco or nec"
exit
fi
The above code did not work for me, so I tried this instead:
if [ "$PHONE_TYPE" == "NORTEL" ] || [ "$PHONE_TYPE" == "NEC" ] ||
[ "$PHONE_TYPE" == "CISCO" ]
then
: # do nothing
else
echo "Phone type must be nortel,cisco or nec"
exit
fi
Are there cleaner ways for this type of task?
shell
script, both in the tags, and in the question. This answer would fail in a POSIX environment. – Jack_Hu May 16 '21 at 17:21