[lldb] Shell expansion should happen at input (not launch) time
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
# Shell expansion should happen at input time, not launch time
## Problem
Currently, lldb stores arguments in `target.run-args` unexpanded, then shell-expands them at launch time. This causes a usability issue:
- **CLI args are expanded twice**: When running `lldb prog -- arg*`, the user's shell expands `arg*` first. Then lldb stores the result in `target.run-args`. On launch, lldb expands again. This double-expansion is redundant at best, and on zsh/fish/tcsh causes failures when globs don't match (see #112107).
- What complicates a simple fix for this is there's no way to distinguish arg sources: lldb can't tell whether args came from the CLI (already expanded) or were typed in the REPL (may need expansion). Both end up in `target.run-args` and get the same treatment.
## Proposal
Move shell expansion to input time instead of launch time:
- When args are passed to `process launch`, expand them immediately (with `-X true`)
- Store literal (i.e. already expanded) args in `target.run-args`
- At launch time, use args verbatim (no expansion)
- Pass CLI args (which are already expanded by the user's shell) without expansion
This way:
- CLI args work as expected
- Stored args are passed as-is
- No zsh/fish/tcsh failures on unmatched globs
- Can use `settings set target.run-args` to pass literal args
A downside to this change would be the loss of a way to set `target.run-args` with shell expansion.
This could be amended by adding a `-X` flag to `settings set`, which would also make expansion available when setting other variables, like `target.env-vars`.
Contributor guide
Research direction
Start with the process launch and settings set target.run-args entry points described in the proposal. Trace where -X true is handled and where target.run-args are stored and consumed. Done means CLI arguments are not expanded again, REPL arguments are expanded at input time, stored arguments are passed verbatim, and the settings behavior is addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- cli, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100