Estou curioso, o que este script está fazendo?
#!/bin/bash
for x in $@
do
array[$i]=$x
i=$((i+1))
done
# initial state
state=S0
for((i=0;i<${#array[@]};i++))
do
case $state in
"S0")
if [ ${array[$i]} == I0 ]
then
state=S1
output[$i]=O1
elif [ ${array[$i]} == I1 ]
then
state=S0
output[$i]=O0
fi
;;
"S1")
if [ ${array[$i]} == I0 ]
then
state=S1
output[$i]=O1
elif [ ${array[$i]} == I1 ]
then
state=S0
output[$i]=O0
fi
;;
esac
done
echo "final state="$state
echo "output="${output[@]}