-
Notifications
You must be signed in to change notification settings - Fork 26
feat: add _bash suffix env vars for variadic args #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
For variadic arguments (var=true), as_env() now emits an additional
environment variable with a _bash suffix containing a bash array literal
that can be directly eval'd into a bash array.
Example:
- usage_files="arg1 'arg with space'" (existing format)
- usage_files_bash="(arg1 'arg with space')" (new format)
This allows bash scripts to properly handle variadic args with spaces:
```bash
eval "files=$usage_files_bash"
for f in "${files[@]}"; do echo "$f"; done
```
This addresses the long-standing issue where the shell-escaped string
format couldn't be reliably converted back into separate arguments in
bash without using fragile eval workarounds.
Closes #189
Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Warning Gemini encountered an error creating the summary. You can try again by commenting |
|
Closing in favor of documentation - users can simply use |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #479 +/- ##
=======================================
Coverage 70.57% 70.58%
=======================================
Files 47 47
Lines 6597 6694 +97
Branches 6597 6694 +97
=======================================
+ Hits 4656 4725 +69
- Misses 1264 1280 +16
- Partials 677 689 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is ON, but a Cloud Agent failed to start.
| if let ParseValue::MultiString(s) = val { | ||
| let bash_val = format!("({})", shell_words::join(s)); | ||
| env.insert(format!("{}_bash", key), bash_val); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential key collision with _bash suffix naming
Low Severity
The _bash suffix appended to variadic arg keys can silently collide with existing arg/flag names. If a user has a variadic arg named "files" (producing usage_files_bash) and another arg/flag named "files_bash", "files-bash", or "FilesBash" (all producing usage_files_bash after to_snake_case), the values would silently overwrite each other in the BTreeMap. No warning or error is produced.


Summary
For variadic arguments (
var=true),as_env()now emits an additional environment variable with a_bashsuffix containing a bash array literal that can be directly eval'd into a bash array.Example:
usage_files="arg1 'arg with space'"(existing format)usage_files_bash="(arg1 'arg with space')"(new format)This allows bash scripts to properly handle variadic args with spaces:
Problem
The existing shell-escaped string format (
'arg1' 'arg with space') cannot be reliably converted back into separate arguments in bash without fragile workarounds. Users had to use patterns like:This has been a long-standing pain point for mise task authors.
Solution
Add a second env var with
_bashsuffix that contains a bash array literal:usage_files_bash="(arg1 'arg with space')"Users can now simply:
Backwards Compatibility
usage_*variables remain unchanged_bashsuffixed variables forMultiString(variadic) values_bashsuffixTest plan
_bashsuffixCloses #189
🤖 Generated with Claude Code
Note
Low Risk
Low risk: this only adds additional
usage_*_bashoutputs forMultiStringvalues and updates tests; existing env var keys/values remain unchanged.Overview
ParseOutput::as_env()now emits an extrausage_<name>_bashenvironment variable for variadic (MultiString) args and flags, formatted as a bash array literal (e.g.,(arg1 'arg with space')) while keeping existingusage_<name>values unchanged.Adds/updates unit and integration tests to validate the new
_bashvariables (including spaced and single-element values) and ensure non-variadic args do not receive the suffix.Written by Cursor Bugbot for commit b6eb9d4. This will update automatically on new commits. Configure here.