-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
vscode adding escapes to args supplied via launch.json configuration. python sys.argv sees VS code's arguments not those specified in launch.json. #149391
Comments
I'm also encountering this and it seems to be due to the most recent update:
My configuration contains a {
"name": "Cluster",
"type": "python",
"justMyCode": false,
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"shell",
"<",
"${workspaceFolder}/launch_cluster.py"
],
"preLaunchTask": "checkServer",
"django": true
}, Produces an error because the generated command is: |
This will be fixed in 1.67.2 (releasing in a couple hours) #148887 |
I don't think this issue was fully fixed. I still see spaces being escaped. Here is a minimal reproducible example. {
"name": "Example escaped launch.json config",
"type": "python",
"request": "launch",
"program": "example.py",
"args": [
"foo bar"
]
}, I get the output:
Notice how a slash was added between "foo" and "bar" In this contrived example I understand that I could fix this by using
But I cannot do that with how I actually want to use launch.json My real world example is this: {
"name": "Python: Django Debug Single Test",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"test",
"`echo -n ${relativeFileDirname} | tr \/ .`.${fileBasenameNoExtension}"
],
"django": true
} but every space in that second argument gets escaped and it breaks the command :( |
The history is this - we were not fully escaping arguments, making it impossible to pass some special characters to a program as args. #145265. I think we never intended to enable arbitrary shell scripts in launch.json args, but it worked because arg escaping was incomplete. My view is that args should be arguments passed to a program, not a shell script which only works in a particular shell. Since lots of people were using < and > for input and output redirection, our compromise was not escaping those characters when they are alone in an arg. But other characters will be escaped so they can be passed literally to a program. There might be another way you can get the same transformation like by doing it in your .py file. That would be platform-independent too. Not sure what are all the options that the python debugger has but maybe you can start a shell script. |
If needed, we can continue this in #149910 |
Does this issue occur when all extensions are disabled?: Yes
runInTerminal
with spaces and single quotes makes launch fail #125934Steps to Reproduce:
C:\
argument is received by Python asC:\\
(4 characters). Effectively, VSCode is adding a character to the specified argument.launch.json with C:\ argument:
display_argv.py:
The display_argv.py output observed upon repro:
The text was updated successfully, but these errors were encountered: