Bash parser reports errors on correct arithmetic expressions


I’ve been learning Bashscript for a month now with Clash of Code battles and I’ve noticed that the Bash syntax checker sometimes reports errors on some arithmetic expressions when it shouldn’t. I’ve made a small list below of encountered cases.

  • d=$(( ($a-$b)**2 + ($c-$d)**2 )) This is a simple example here, the whole line is underlined in red. I found that when using parenthesis inside an arithmetic expression the syntax checker tends to get mad
  • until ((i==5)); do ... done The ((i==5)) part is flagged as incorrect, while it shouldn’t, as using an arithmetic operation to perform a test is normally possible in Bash. One strange thing : while ((i==5)); do ... done doesn’t have this problem (with the exact same code instead of ...)
  • (EDIT 1 : I add this case) the syntax coloration has a problem when nesting array brace expansion. For instance this simple (useless) code
    echo "${a[${b[0]}]}"
    prints the value of “a(b(0))”, which is 123. On the last line only the ${a[${b[0]} part is treated as a brace expansion and colored in blue in the CoC IDE, and the last ]} is missing.

I hope it helps, I will add more cases to this list if I find some other ones.

One last thing, I noticed that it is possible to list files in the current directory with echo * (I found this accidentally, I actually wanted to just print *). By searching a bit more, I found out that it is possible to run ls -l and easily explore the whole filesystem (it isn’t possible to print the solution though, as we don’t have permission to read the file out.txt). I’m not sure whether this is on purpose or not but I report this here.


not on purpose but it happens that the version used in the Language Server Protocol (LSP) is slightly different than the language version of the IDE. Will be fixed with a future update of LSP