BashSupport-Pro / bashsupport-pro

Public issue tracking for BashSupport Pro. This is a plugin, which provides advanced support for Bash scripts for JetBrains IDEs.
https://www.bashsupport.com
48 stars 2 forks source link

Do not escape single quote when running bash snippet in markdown #167

Closed viocha closed 5 months ago

viocha commented 5 months ago

When running the following bash snipppet from markdown file

echo "abc"
bash -c 'echo 123'

It generates the run commmand as

C:\Windows\system32\wsl.exe -d Ubuntu -e bash -c "echo \\"abc\\"
bash -c \'echo 123\'"

And the running fails with errors

"abc"
123': -c: line 1: unexpected EOF while looking for matching `''
123': -c: line 2: syntax error: unexpected end of file

There is no need to escape single quote in double quoted string. If the generated run command is

C:\Windows\system32\wsl.exe -d Ubuntu -e bash -c "echo \\"abc\\"
bash -c 'echo 123'"

It can run successfully.

jansorg commented 5 months ago

Thanks for reporting! Without WSL (e.g. on Linux or macOS), the snippet is executed properly:

/usr/bin/bash -c "echo \"abc\"
bash -c 'echo 123'" /usr/bin/bash

There's probably some double-escaping by the WSL integration, I'll see what's possible to fix this.

jansorg commented 5 months ago

I'll fix this for the next update. There are a few more problems in regard to escaping of snippets, e.g. $VAR needs to be escaped, but only if it's outside a single escaped string. For WSL, there's an extra level of escaping because the first evaluation happens by wsl.exe and not Bash. I'll have to carefully review all cases and hope to have a complete and reliable fix for the next update.

jansorg commented 5 months ago

@viocha I've published a fixed version on the eap channel: https://plugins.jetbrains.com/plugin/13841-bashsupport-pro/edit/versions/eap/565897 Do you mind to install this version and confirm if it's working as expected? In general, the new version should work better on Windows. But because of the changes I'm looking for testers...

jansorg commented 5 months ago

4.2.1 is public now and ships the fix.