Hi guys,
Can you please help me modify my script, I know I'm pretty close but I need someone help to nail it
Here's my code :
As you can see the red one, I'm trying to change the $flag value if enter is pressed.
But the fact is the $flag always true
Thanks guys
Can you please help me modify my script, I know I'm pretty close but I need someone help to nail it
Here's my code :
Code:
readkey() {
oldstty=`stty -g`
stty -icanon -echo min 0 time 100
dd bs=1 count=1 <&0 2>/dev/null
stty $oldstty
}
process() {
mychar=
mystring=
flag="true"
echo "$START_INPUT\c"
while true
do
mychar=$(readkey)
if [[ -z $mychar ]];then
break
fi
if [[ "$mychar" = "^?" ]];then
if [[ ${#mystring} -gt 0 ]];then
tput cub1 ; echo " \c" ; tput cub1
mystring="${mystring%?}"
fi
elif [font color=red][[ "$mychar" == "^M" ]][/font];then
flag="false"
echo "flag $flag\c"
break
else
echo "$mychar\c"
mystring="$mystring"$mychar
fi
done
echo $flag
SEL=$mystring
echo "$END_INPUT\c"
if [[ "$flag" == "true" ]];then
timeout
fi
}
But the fact is the $flag always true
Thanks guys