vscode: Terminal on Windows uses `cmd /C`, this corrupts passed arguments
Environment data
- VS Code version: 1.62.2
- Extension version: v2021.12.1559732655
- OS and version: Windows 8.1
- Python version: Python 3.6
Steps to reproduce:
Using the following Python script (try-argparse.py
)
import sys
print(f'sys.argv: {sys.argv}')
with this launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File with arguments",
"type": "python",
"request": "launch",
"program": "${file}",
"args": [
"-f",
"\"AMOUNT>=0,06\""
]
}
}
Because I have a >
in the argument I have to put the argument in double quotes.
Executing the config results in the following command in the terminal:
c: && cd c:\test && cmd /C "c:\Python36\python.exe c:\Users\XXXX\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\launcher 60722 -- c:\test\try-argparse.py -f """AMOUNT>=0,06""" "
The output in the terminal:
sys.argv: ['c:\\test\\try-argparse.py', '-f', '"AMOUNT,06"']
The >
is gone (cmd
removes it), and I get extra "
characters.
If I start the debugger with the following command (no cmd /C "..."
):
c: && cd c:\test && c:\Python36\python.exe c:\Users\XXXX\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy --listen 60722 c:\test\try-argparse.py -f "AMOUNT>=0,06"
I can add the argument --wait-for-client
if I want to attach to the debugger with VSC.
I get in the terminal
sys.argv: ['c:\\test\\try-argparse.py', '-f', 'AMOUNT>=0,06']
The correct argument as set in the launch config.
What is the reason to use cmd /C "debug launch command"
?
And in this process the "
in the argument gets transformed to """
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 25 (12 by maintainers)
Commits related to this issue
- Also escape pipe character in bash shell. #145265 — committed to microsoft/vscode by roblourens 2 years ago
- Fix bad regex #145265 — committed to microsoft/vscode by roblourens 2 years ago
- Fix bad regex #145265 — committed to microsoft/vscode by roblourens 2 years ago
@roblourens
It is for bash but the first user with a problem passing regex arguments.
Why is the
|
character not part of the to-be-quoted characters for bash.btw. Only
\
and]
need to be escaped inside a[]
construct in a regex. Technically]
not if it is the first character or the first after^
if it is a[^]
construct.