docs(tasks): add bash array pattern for variadic args - #7914
Conversation
Document how to properly convert variadic args to bash arrays using eval "arr=($usage_var)" pattern. This handles arguments with spaces correctly. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @jdx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the documentation for Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR documents a recommended pattern for handling variadic task arguments that contain spaces in bash scripts, addressing a common user pain point discussed in issue #6766.
Changes:
- Added documentation for the
eval "files=($usage_files)"pattern to convert variadic args to bash arrays - Included examples showing proper array usage with
"${files[@]}"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ```bash | ||
| # Convert to bash array: | ||
| eval "files=($usage_files)" |
There was a problem hiding this comment.
Using eval with user-provided input is a security risk. If $usage_files contains malicious code, it will be executed. Consider documenting safer alternatives like mapfile or readarray, or at minimum add a security warning about validating input before using eval.
| eval "files=($usage_files)" | |
| files=($usage_files) |
| [tasks.process] | ||
| usage = 'arg "<files>" var=#true' | ||
| run = ''' | ||
| eval "files=($usage_files)" |
There was a problem hiding this comment.
Using eval with user-provided input is a security risk. If $usage_files contains malicious code, it will be executed. Consider documenting safer alternatives like mapfile or readarray, or at minimum add a security warning about validating input before using eval.
| eval "files=($usage_files)" | |
| # Safely read the usage_files into a Bash array without using eval | |
| mapfile -t files <<< "$usage_files" |
There was a problem hiding this comment.
Code Review
This pull request significantly enhances the documentation for handling variadic arguments in mise tasks, particularly addressing the common challenge of arguments containing spaces in bash scripts. The added tip boxes provide clear and practical examples, which will be very helpful for users. The use of eval for parsing shell-escaped strings into bash arrays is an idiomatic solution for this problem, and the examples demonstrate its application effectively.
|
|
||
| ```bash | ||
| # Convert to bash array: | ||
| eval "files=($usage_files)" |
There was a problem hiding this comment.
The eval command is powerful and can be a security risk if the $usage_files variable were to contain untrusted or malicious input, as eval executes arbitrary shell commands. While this pattern is a common and often necessary way to parse shell-escaped strings into arrays in bash, it's generally good practice to include a small cautionary note about the potential risks of eval when dealing with potentially untrusted input, or to emphasize that usage_files should always be from a trusted source.
| [tasks.process] | ||
| usage = 'arg "<files>" var=#true' | ||
| run = ''' | ||
| eval "files=($usage_files)" |
Clarifies that readarray/mapfile are alternatives in bash 4.0+, but macOS ships with bash 3.2 by default which doesn't include them. The eval pattern works with all bash versions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
readarray/mapfile don't understand shell quoting, so they wouldn't work with the current format regardless of bash version. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.9 x -- echo |
15.7 ± 0.3 | 15.0 | 17.1 | 1.00 |
mise x -- echo |
15.9 ± 0.4 | 14.8 | 18.7 | 1.02 ± 0.04 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.9 env |
15.3 ± 0.4 | 14.5 | 19.6 | 1.00 |
mise env |
15.7 ± 0.6 | 14.5 | 19.7 | 1.02 ± 0.05 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.9 hook-env |
15.5 ± 0.4 | 14.4 | 17.0 | 1.00 |
mise hook-env |
16.1 ± 0.4 | 15.1 | 17.6 | 1.04 ± 0.04 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.9 ls |
13.9 ± 0.3 | 13.0 | 15.0 | 1.00 |
mise ls |
15.0 ± 0.5 | 14.0 | 16.8 | 1.08 ± 0.04 |
xtasks/test/perf
| Command | mise-2026.1.9 | mise | Variance |
|---|---|---|---|
| install (cached) | 81ms | 84ms | -3% |
| ls (cached) | 54ms | 57ms | -5% |
| bin-paths (cached) | 56ms | 58ms | -3% |
| task-ls (cached) | 232ms | -49% |
## Summary
Documents how to properly convert variadic args (`var=#true`) to bash
arrays using the pattern:
```bash
eval "files=($usage_files)"
```
This handles arguments with spaces correctly.
## Changes
- Added tip box in the Variadic Arguments section explaining the pattern
- Added tip box after Example 4 in the migration guide showing the
complete pattern
## Example
```bash
# Convert to bash array:
eval "files=($usage_files)"
# Use as array:
for f in "${files[@]}"; do
echo "Processing: $f"
done
```
This addresses the common issue discussed in jdx#6766 where users struggle
to handle variadic args with spaces in bash scripts.
Related:
- jdx#6766
- jdx/usage#189
- jdx/usage#480
🤖 Generated with [Claude Code](https://claude.ai/code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk documentation-only change that adds usage guidance and
examples; no runtime or behavior changes.
>
> **Overview**
> Documents a recommended Bash pattern for variadic task args
(`var=#true`) that may include spaces, showing how to `eval
"files=($usage_files)"` and then consume the resulting array safely.
>
> Adds two new *tip* callouts: one in the `Variadic Arguments` section
and another in the migration guide’s variadic example, both providing
the same array-conversion snippet and usage examples.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
905ebdf. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
### 🐛 Bug Fixes - **(task)** resolve monorepo task includes relative to config file directory by @jdx in [jdx#7917](jdx#7917) - disable autocrlf on git clone to fix WSL issues by @jdx in [jdx#7916](jdx#7916) ### 📚 Documentation - **(tasks)** add bash array pattern for variadic args by @jdx in [jdx#7914](jdx#7914)
Summary
Documents how to properly convert variadic args (
var=#true) to bash arrays using the pattern:This handles arguments with spaces correctly.
Changes
Example
This addresses the common issue discussed in #6766 where users struggle to handle variadic args with spaces in bash scripts.
Related:
var=truejoining usage#189🤖 Generated with Claude Code
Note
Low Risk
Low risk documentation-only change that adds usage guidance and examples; no runtime or behavior changes.
Overview
Documents a recommended Bash pattern for variadic task args (
var=#true) that may include spaces, showing how toeval "files=($usage_files)"and then consume the resulting array safely.Adds two new tip callouts: one in the
Variadic Argumentssection and another in the migration guide’s variadic example, both providing the same array-conversion snippet and usage examples.Written by Cursor Bugbot for commit 905ebdf. This will update automatically on new commits. Configure here.