I'm writing a simple terminal input script for Dingux that I call Terminoo. The script runs fine but it seems to simply freeze with no input or output whatsoever (but no syntax errors). I'm new to Linux bash scripting so I'm not particularly sure what the problem is, so I could use some help. My script is as follows:
#!/bin/sh
# Terminoo r3 - Terminal input for the Dingux via Dpad.
# Controls:
# Up - Confirm Letter
# Down - Erase Letter. If no letters left will recall last command if available.
# Left - Scroll backwards through alphabet. Symbols not yet implemeted.
# Right - Scroll forwards through alphabet. Symbols not yet implemeted.
# Start - Confirm command. Also saves command for recall.
# Select - Exit to launcher.
# Features:
# Saves last command.
# Able to execute bash commands on the fly from the Dingoo.
# To Do:
# Implement symbol input.
# Proper implementation of letter input.
# Use of A,B,X,Y buttons.
# Credits:
# Coded by n4ru (c) 2010
export SDL_NOMOUSE=1
resetVariables()
{
inputletter="A"
inputnumber="1"
string=""
stringlen="0"
}
setVars()
{
if [ "$inputnumber" = "0" ]
then inputnumber="26"
fi
if [ "$inputnumber" = "27" ]
then inputnumber="1"
fi
if [ "$inputnumber" = "1" ]
then inputletter="A"
fi
if [ "$inputnumber" = "2" ]
then inputletter="B"
fi
if [ "$inputnumber" = "3" ]
then inputletter="C"
fi
if [ "$inputnumber" = "4" ]
then inputletter="D"
fi
if [ "$inputnumber" = "5" ]
then inputletter="E"
fi
if [ "$inputnumber" = "6" ]
then inputletter="F"
fi
if [ "$inputnumber" = "7" ]
then inputletter="G"
fi
if [ "$inputnumber" = "8" ]
then inputletter="H"
fi
if [ "$inputnumber" = "9" ]
then inputletter="I"
fi
if [ "$inputnumber" = "10" ]
then inputletter="J"
fi
if [ "$inputnumber" = "11" ]
then inputletter="K"
fi
if [ "$inputnumber" = "12" ]
then inputletter="L"
fi
if [ "$inputnumber" = "13" ]
then inputletter="M"
fi
if [ "$inputnumber" = "14" ]
then inputletter="N"
fi
if [ "$inputnumber" = "15" ]
then inputletter="O"
fi
if [ "$inputnumber" = "16" ]
then inputletter="P"
fi
if [ "$inputnumber" = "17" ]
then inputletter="Q"
fi
if [ "$inputnumber" = "18" ]
then inputletter="R"
fi
if [ "$inputnumber" = "19" ]
then inputletter="S"
fi
if [ "$inputnumber" = "20" ]
then inputletter="T"
fi
if [ "$inputnumber" = "21" ]
then inputletter="U"
fi
if [ "$inputnumber" = "22" ]
then inputletter="V"
fi
if [ "$inputnumber" = "23" ]
then inputletter="W"
fi
if [ "$inputnumber" = "24" ]
then inputletter="X"
fi
if [ "$inputnumber" = "25" ]
then inputletter="Y"
fi
if [ "$inputnumber" = "26" ]
then inputletter="Z"
fi
}
terminalEntry()
{
read -s -n 3 -p "CMD $string$inputletter" change
if [ "$change" = "[C" ]
then
((inputnumber++))
setVars
fi
if [ "$change" = "[D" ]
then
((inputnumber--))
setVars
fi
if [ "$change" = "[A" ]
then
((stringlen++))
string = "$string$inputletter"
inputletter="A"
inputnumber="1"
fi
if [ "$change" = "[B" ]
then
if [ "stringlastactive" = "1" && "$stringlen" = "0"]
then
string="$stringlast"
stringlen="$stringlenlast"
else
((stringlen--))
string="${string%?}"
fi
inputletter="A"
inputnumber="1"
fi
if "$change"=="["
then
exit
else
$string
resetVariables
stringlenlast="$stringlen"
stringlast="$string"
stringlastactive="1"
fi
terminalEntry
}