-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
terminal.integrated.shellArgs.windows user setting ignores quotes, and escape sequences #57452
Comments
This is related to the way that we're computing the "Command Line" string in node-pty, here's the code pointer: The fix here may be to allow passing in a raw string like is allowed in tasks https://github.com/Microsoft/node-pty/blob/cafed13d456fa37df46a9dc26f9a5ebdfe88f3f6/src/windowsPtyAgent.ts#L121 Interested in your thoughts on this @dbaeumer; should |
Since this is already OS & Shell specific I would stick with one string which is exactly pass this way to the shell. Then it is clear how it is for example quoted. I see no benefit for a |
@dbaeumer you mean allow a |
Changing the way you're interpreting the string(s) might also break people (since quotes that you're dropping would suddenly not be dropped and cause a JSON parsing failure instead). But I think it's a good change regardless. You might have a helpful error message that links to a doc describing the change though. |
@Tyriar my misunderstanding. Then it should be |
@sandy081 is it possible to have VS Code settings be union types. I want to have a |
This has to be supported by JSON Schema.. @aeschli ? |
Try something like: {
"properties": {
"terminal.integrated.shellArgs.windows": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string",
"description": "%arg.desc%"
},
},
{
"type": "string",
"description": "%arg.desc%"
}
],
"default": []
}
}
} |
I tried this out, and it looks like even using |
If you're using |
Looks like I was hitting a separate issue. |
Work around #57452 by allowing a raw string for windows shell args
With the work around in #57971 you can put all the arguments in one string instead of an array. With microsoft/node-pty#222 , the actual escaping issue is fixed. |
@dbaeumer The task does not run, maybe that's expected because the task is passed to the shell as a parameter? My settings:
My tasks.json:
echo.bat:
The output is:
When I remove the shell arguments, the task runs as expected. |
Also: With the quotes the terminal (without task) now opens with an error: That seems unexpected. Reopening. |
@chrmarti this is not meant to work, the quoting should happen for you:
Verification steps:
|
There is an issue with terminalTaskSystem which is not doing any escaping. However I think there's also some contention between As far as I understand, the way it actually works is the task command + parameters are passed as additional parameters when starting your terminal with shell args. So, the whole line would look something like(if we were escaping it correctly):
I assume that instead you wanted to run the shell args and then the task sequentially. It seems like for tasks we should start the terminal with the |
@alexr00 tasks need to finish though and they won't if you just launch the shell and run some stuff. Also I think that would be a pretty radical departure from the current design. |
In that case, the task and |
The original issue where the terminal was incorrectly escaping has been fixed. Opened a new issue to figure out how to reconcile |
What is the correct format of that setting now? I tried both (with escaped double quotes and without) and neither seems to work. I either get |
Looks like this has completely regressed. It only ever worked in insiders, so moving this to November. |
After discussing this with @alexr00, it is my understanding that this has been an issue in stable for long. Given that we're at the end of endgame and it's not a regression nor severe, I'll push this out to November. |
@roblourens, can you confirm whether C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat actually exists? I realized I don't have that file and tried again with a file I do have and it works. |
Yeah it does exist |
Very nice, @damianog. I made a couple changes so I could use the VsDevCmd script and still launch powershell: "terminal.integrated.env.windows": {
"VsDevCmd": "\"C:\\Program Files (x86)\\Microsoft Visual Studio\\IntPreview\\Common7\\Tools\\VsDevCmd.bat\""
},
"terminal.integrated.shell.windows": "C:\\WINDOWS\\system32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"%VsDevCmd%",
"&&",
"%windir%\\system32\\windowspowershell\\v1.0\\powershell.exe"
], |
I still can't repro this. I'm using this:
Can one of the folks who is still seeing space escape issues try this out? |
@alex00 Are you trying my original repro steps? Remember that this alone will allow the terminal to launch, but it's the VS Code "tasks" to fail. |
Issue Type: Bug
As described in this blog post, add these settings to the User Settings json file (adjusting for your actual VS 2017 install dir as necessary):
As (somewhat) expected, this gets the VS Code Terminal running with the VsDevCmd.bat script started first. But this doesn't include quotes around the VsDevCmd.bat script. While this works in the simple Terminal window case, it causes any VS Code "tasks" to fail with this bizarre error:
So we need to add quotes, apparently. But here's where the VS Code bug comes in. Given this is JSON, I should be able to add quotes by escaping them:
But VS Code doesn't interpret the escape sequences and instead keeps the backslashes in the string, producing this error when I open a terminal window:
Very oddly, this syntax is accepted:
Note the above isn't even valid JSON since the inside quotes aren't properly escaped. Yet VS Code happily runs with this and spawns the process... with the inner quotes dropped, which means it doesn't actually solve my problem because once again, the VS Code tasks fail because of the missing quotes around that script.
Can we please get this JSON file properly interpreted, including escape sequences, so that we can use quotes in these shell args?
This seems closely related to #44152 but as that is focused on tasks inheriting a common environment, I think a separate issue tracking just supporting using quotes inside shell arguments is worthwhile and would solve my issue.
VS Code version: Code 1.26.1 (493869e, 2018-08-16T18:38:57.434Z)
OS version: Windows_NT x64 10.0.17134
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Extensions (29)
(1 theme extensions excluded)
The text was updated successfully, but these errors were encountered: