Syntax highlighting is one problem
Each editor has its own dis-/advantages in this manner.
See my question on SoftwareRecs and its respective answers, most importantly this for both CLI and GUI and this for GUI.
Notably, Visual Studio Code, has IMHO the best Syntax highlighting from GUI editors.
From CLI editors, refer to the answer of gVim, which does the same syntax highlighting job for CLI.
Note that as I was a heavy nano user, I can tell you nano can't distinguish the variables inside quotes.
Missing double quotes are a bigger problem
What should trouble you most is that you did not use - I suppose you're not used to it - bad habit - the double quotes. Please refer to StackOverflow for more information or simply use Google.
PS: Or see below.
Always pipe your scripts to ShellCheck
PPS:
Double quote to prevent globbing and word splitting
For shell script writers, nano editor is hardly usable, because it won't recognize variables from inside string (quotes), which is very bad for every shell script writer. Double quotes are completely essential in shell scripts. They prevent so called globbing and word splitting, read ShellCheck Wiki article SC2086 for more information about this topic.