I'm trying to see if first argument exists in an array:
#!/bin/bash
action="$1"
actions=( install run )
actionOK=false
for i in "${actions[@]}"
do
if [ $i=$action ]; then
actionOK=true
fi
done
echo $actionOK
if [ $actionOK = false ]; then
echo "unknown action: $action"
fi
now when trying wan27 run, the script echoes true, but it also echoes true for an action that is not in array, such as test, foo, bar or whatever