Skip to content

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 30, 2026

Summary

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:

eval "files=$usage_files_bash"
for f in "${files[@]}"; do echo "$f"; done

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:

eval "files=(${usage_files})"  # Fragile - double parentheses needed

This has been a long-standing pain point for mise task authors.

Solution

Add a second env var with _bash suffix that contains a bash array literal:

usage_files_bash="(arg1 'arg with space')"

Users can now simply:

eval "files=$usage_files_bash"
touch "${files[@]}"

Backwards Compatibility

  • Existing usage_* variables remain unchanged
  • Only adds new _bash suffixed variables for MultiString (variadic) values
  • Non-variadic args do not get a _bash suffix

Test plan

  • Added unit tests for bash array format
  • Added tests for single-element variadic args
  • Added tests verifying non-variadic args don't get _bash suffix
  • Updated integration tests

Closes #189

🤖 Generated with Claude Code


Note

Low Risk
Low risk: this only adds additional usage_*_bash outputs for MultiString values and updates tests; existing env var keys/values remain unchanged.

Overview
ParseOutput::as_env() now emits an extra usage_<name>_bash environment variable for variadic (MultiString) args and flags, formatted as a bash array literal (e.g., (arg1 'arg with space')) while keeping existing usage_<name> values unchanged.

Adds/updates unit and integration tests to validate the new _bash variables (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.

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]>
Copilot AI review requested due to automatic review settings January 30, 2026 18:00
@gemini-code-assist
Copy link

Warning

Gemini encountered an error creating the summary. You can try again by commenting /gemini summary.

@jdx
Copy link
Owner Author

jdx commented Jan 30, 2026

Closing in favor of documentation - users can simply use eval "files=($usage_files)" to achieve the same result without needing a new env var.

@jdx jdx closed this Jan 30, 2026
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 74.00000% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.58%. Comparing base (16f3858) to head (b6eb9d4).

Files with missing lines Patch % Lines
lib/src/parse.rs 74.00% 15 Missing and 11 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@cursor cursor bot left a 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);
}
Copy link

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.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

alternative var=true joining

2 participants