It seems to me (and correct me if I'm wrong please) that bash is quite bad at error messages that correctly tell you where the problem in your script is. For example, often I will get "bad EOF at line 953". What this really means is that there is a missing fi
at line 127. Or, another classic is "-bash: line 60: syntax error near unexpected token '('". What this really means is that I have redeclared my function mything() {}
as an alias at line 739 alias mything=
, except that, the bash error points to line 60 where there is no actual problem (so it took me a while to find the culprit at line 739).
I tried to load the top hit 'bash debug' tool into VS Code and I was unable to get that to work (I press F5 to run, then a box appears saying "choose a debugger" so I select bash debug and nothing happens). I've tried an online tool that allows running code interactively and says that it can help with debugging, but that also did not help. I do some PowerShell and it does quite a bit better job at reporting the source of a problem. Are there ways (tools, or script analysis tools on github or online that can scan a script for issues like functions and aliases being redeclared with the same name and other tests like that) that enable us to debug bash scripts a bit better?