red / VScode-extension

Red extension for Visual Studio Code
Boost Software License 1.0
40 stars 17 forks source link

Fix command syntax for win32 platform #48

Closed Sinister78 closed 3 years ago

Sinister78 commented 3 years ago

The 'Run Current Script' and 'Run Current Script in GUI Console' commands were giving the following error: 'The filename, directory name, or volume label syntax is incorrect.' Changed from enclosing the command and argument in single quotes, to adding an extra double quote in front of the command.

Reference: https://ss64.com/nt/cmd.html

bitbegin commented 3 years ago

have you tested it with powershell/bash ?

Sinister78 commented 3 years ago

I hadn't tested in the other shells. I modified the command again (added '--%' after 'cmd') and it now runs under PowerShell as well as Command Prompt, but not Bash.

I don't think there's a syntax that works in all 3 shells. If you remove the 'cmd /C' and the extra double quote, it works in CMD and Bash but not in PowerShell. The only way to get it to work in PowerShell is to either leave 'cmd --%' or remove all quotes and backtick the spaces, but then it doesn't work in the other shells.

Sinister78 commented 3 years ago

In the Python extension, it looks like they test for TerminalShellType and run different syntax based on target shell. For PowerShell they add a '& ' in front of the command with paths surrounded by quotes:

& "C:/Test Dir/red.exe" --cli "C:/Test Dir/hello-world.red"

qtxie commented 3 years ago

@Sinister78 Thanks a lot. 👍