Issue 176881
Summary [lldb] Shell expansion should happen at input (not launch) time
Labels new issue
Assignees
Reporter roysc
    # 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`.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to