这是产生错误的代码:
#!/bin/bash
types=([i]=Info [w]=Warning [e]=Error [se]=Severe)
function isValidType
{
for type in "${!types[@]}"
do
if [ $1 == $type ]; then
return 0
fi
done
return 1
}
if [ isValidType "$msgType" -eq 1 ]; then # <---- error here
echo "Invalid type."
exit 0
fi