0

I am trying to create a script which quizzes users on language vocabulary.

Here it is so far:

while read line
do
  trans -s es -brief "$line"
  read -r answer < /dev/tty
  echo -en "\e[2A"; echo -e "\e[0K\r$line"
  say -v Jorge "$line"
  if ["$answer" == "$line"]; then
    echo -en "\e[1A"; echo -e "\e[0K\rcorrect"
  else
    echo -en "\e[1A"; echo -e "\e[0K\rwrong"
  fi
done

and when run (the file passed via stdin can look like this):

No matter what I enter, for some reason bash is printing wrong even though it should be correct.

Community
  • 1
  • 1
theonlygusti
  • 7,942
  • 8
  • 40
  • 80
  • @andlrc I already tried this: `["$answer\n" == "$line"]` but it changed nothing. I will try what you just proposed though. – theonlygusti Nov 01 '16 at 23:41
  • That not what I said though, `["$answer" == "$line"]` -> `[ "$answer" = "$line" ]` or `[[ "$answer" = "$line" ]]` – andlrc Nov 01 '16 at 23:43
  • @andlrc I just tried what you said and it hasn't worked. That command changed nothing from my previous observations. Sorry for maybe assuming some stuff, I am still _very_ new to bash :P – theonlygusti Nov 01 '16 at 23:46

0 Answers0