Skip to content

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 30, 2026

Summary

Documents how to properly convert variadic args (var=#true) to bash arrays using the pattern:

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

# 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 #6766 where users struggle to handle variadic args with spaces in bash scripts.

Related:

🤖 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 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.

Written by Cursor Bugbot for commit 905ebdf. This will update automatically on new commits. Configure here.

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

Summary of Changes

Hello @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 mise's task system by providing crucial guidance on handling variadic arguments in bash scripts. It introduces a recommended pattern using eval "files=($usage_files)" to correctly parse arguments that may contain spaces into bash arrays, thereby preventing common scripting issues and improving the reliability of task execution.

Highlights

  • Documentation Update: Added a new tip box in the "Variadic Arguments" section of the task-arguments.md documentation to explain how to properly convert variadic arguments into bash arrays, specifically addressing arguments that contain spaces.
  • Example Enhancement: Included a second tip box after "Example 4" in the migration guide within task-arguments.md, providing a complete example of the pattern for handling variadic arguments with spaces by converting them to bash arrays.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)"
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
eval "files=($usage_files)"
files=($usage_files)

Copilot uses AI. Check for mistakes.
[tasks.process]
usage = 'arg "<files>" var=#true'
run = '''
eval "files=($usage_files)"
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
eval "files=($usage_files)"
# Safely read the usage_files into a Bash array without using eval
mapfile -t files <<< "$usage_files"

Copilot uses AI. Check for mistakes.
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the previous tip, the eval command used here carries potential security risks if $usage_files could be manipulated by untrusted input. It's crucial to ensure that the source of usage_files is always trusted when employing eval in scripts.

jdx and others added 2 commits January 30, 2026 12:19
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 <[email protected]>
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 <[email protected]>
@github-actions
Copy link

Hyperfine Performance

mise x -- echo

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 ⚠️ 461ms -49%

⚠️ Warning: task-ls cached performance variance is -49%

@jdx jdx merged commit 95cc03f into main Jan 30, 2026
36 checks passed
@jdx jdx deleted the docs/bash-array-pattern branch January 30, 2026 18:41
mise-en-dev added a commit that referenced this pull request Jan 31, 2026
### 🐛 Bug Fixes

- **(task)** resolve monorepo task includes relative to config file
directory by @jdx in [#7917](#7917)
- disable autocrlf on git clone to fix WSL issues by @jdx in
[#7916](#7916)

### 📚 Documentation

- **(tasks)** add bash array pattern for variadic args by @jdx in
[#7914](#7914)
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.

2 participants