Skip to content

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

Open
TEJA P C (PCTEJA) wants to merge 1 commit into
microsoft:mainfrom
PCTEJA:fix-debugpy-bash-quoting-820
Open

TEJA P C (PCTEJA) wants to merge 1 commit into
microsoft:mainfrom
PCTEJA:fix-debugpy-bash-quoting-820

Conversation

@PCTEJA

Copy link
Copy Markdown

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"]

The patch was also independently reviewed with Codex (GPT-6 Astra), which re-ran the reproduction plus edge cases (empty argument, tabs/newlines in arguments, wildcards, quotes, backslashes) — all passing — and recommended the narrowed "$@"-only scope described above.

This change was prepared with AI assistance (Muse, validated with Codex); I have reviewed every changed line and take responsibility for it.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debugpy does not quote spaces in command line arguments.

1 participant