Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
viocha opened this issue Jun 19, 2024 · 3 comments
Open

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

viocha opened this issue Jun 19, 2024 · 3 comments

Comments

@viocha
Copy link

viocha commented Jun 19, 2024

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
Copy link
Contributor

jansorg commented Jun 19, 2024

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
Copy link
Contributor

jansorg commented Jun 20, 2024

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
Copy link
Contributor

jansorg commented Jul 2, 2024

@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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants