bash-language-server
bash-language-server copied to clipboard
Failed to parse here document ending with a backslash
Inside vscode, I get 'Failed to parse exception' for the following code:
#! /usr/bin/env bash
f() {
cat << 'EOS'
echo 'test1' \
; echo 'test2' \
EOS
}
f
It works if I add en empty line above the ending EOS, but it ends in the output, which is totally undesirable for my use case. It works also if I just remove the last backslash - but, again, I need that one.
I don't believe this is a bug. You're escaping the return so you're putting the EOS on the same line as test2 so the here doc isn't closed. You can test this interactively a see it continues the input of the here doc.
@derekschrock I did test this before posting. Let me know if you tested and what happened in your case.
Besides testing, look closer - I'm using the quoted form of end of here-string: 'EOS'
Meaning the backslash won't be a continuation line marker.
You would be right if I would have used the non quoted EOS marker.
I reported this bug also to 'shfmt' where it was quickly fixed.
Regards.
Yeah, you're right sorry for that. I missed it was a quoted here-doc. Too late while I was searching issues for my own here-doc related problems.
I have experienced the same problem with the extra caveat that the error reproduction is coupled to the existence of a git repo: If the file I'm editing is inside a git repo I get the error, if I move the file (or remove the .git dir) all is fine. Using the server through terminal vim + ale plugin.