Skip to content

Quote "$@" in bash no-config wrapper so arguments with spaces survive - #1147

Merged
Rich Chiodo (rchiodo) merged 2 commits into
microsoft:mainfrom
PCTEJA:fix-debugpy-bash-quoting-820
Nov 24, 2026
Merged

Rich Chiodo (rchiodo) merged 2 commits into
microsoft:mainfrom
PCTEJA:fix-debugpy-bash-quoting-820

Conversation

@PCTEJA

@PCTEJA TEJA P C (PCTEJA) commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #820.

The bundled bash no-config wrapper bundled/scripts/noConfigScripts/debugpy forwarded unquoted $@, so arguments containing spaces were split before reaching the debug target:

$ debugpy /path/to/script.py hi "hello world"
# target saw argv: ['hi', 'hello', 'world'] instead of ['hi', 'hello world']

Change

One line: forward "$@" instead of $@, so each argument is passed exactly as given. With zero arguments, "$@" correctly expands to no words.

Deliberately out of scope: quoting $BUNDLED_DEBUGPY_PATH on the same line. That changes behaviour when the variable is unset/empty (an empty-string argument would be passed to python3 instead of no argument), so it deserves separate handling with an explicit check rather than being bundled into this fix.

Testing

Reproduced and verified with bash using a stub adapter that prints sys.argv:

  • Before: ["--listen", "0", "--wait-for-client", "/path/to/script.py", "hi", "hello", "world"]
  • After: ["--listen", "0", "--wait-for-client", "/path/to/script.py", "hi", "hello world"]
  • Zero extra arguments still work: ["--listen", "0", "--wait-for-client"]

I have reviewed every changed line and take responsibility for it.

TEJA P C (PCTEJA) and others added 2 commits November 13, 2026 23:02
The bundled bash wrapper forwarded unquoted $@, so an argument
containing a space was split into multiple arguments before reaching
the debug target (e.g. "hello world" arrived as 'hello' and 'world').

Use "$@" so each argument is forwarded exactly as given, including
arguments containing spaces and the zero-argument case.

Fixes microsoft#820
@PCTEJA

Copy link
Copy Markdown
Contributor Author

Hi Rich Chiodo (@rchiodo), would you mind taking a look at this one when you get a chance? It quotes "$@" in the bash no-config wrapper so arguments with spaces survive. Happy to fix anything you spot.

@rchiodo Rich Chiodo (rchiodo) added the bug Issue identified by VS Code Team member as probable bug label Nov 17, 2026
@PCTEJA

Copy link
Copy Markdown
Contributor Author

Rich Chiodo (@rchiodo) The PR is ready to be merged.

@rchiodo
Rich Chiodo (rchiodo) merged commit 84d7555 into microsoft:main Nov 24, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debugpy does not quote spaces in command line arguments.

2 participants