Skip to content

fix(env): parse concatenated short form -Eval correctly#9456

Merged
jdx merged 1 commit intojdx:mainfrom
bts:bts/push-tvouvsvunzvx
Apr 28, 2026
Merged

fix(env): parse concatenated short form -Eval correctly#9456
jdx merged 1 commit intojdx:mainfrom
bts:bts/push-tvouvsvunzvx

Conversation

@bts
Copy link
Copy Markdown
Contributor

@bts bts commented Apr 28, 2026

In the past, mise would correctly parse -Eval (vs e.g. -E val) such that mise.val.toml would be loaded. Currently mise -Eval <cmd> silently fails to load the val environment.

This change re-adds support for this "concatenated short" form to the parser.

See also PR #8889, which previously fixed support for --env=val and -E=val forms.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR re-adds support for the concatenated short-flag form (-Eval) in the environment() arg parser in src/env.rs. The existing code handled --env=val, -E=val, and -E val but silently dropped -Eval; the new branching logic adds that case by splitting at byte index 2 and checking the 2-char prefix against the known flag set.

Confidence Score: 5/5

This PR is safe to merge — the change is a targeted, well-tested fix with no regressions introduced.

No P0 or P1 issues found. The refactored branching logic correctly handles all four flag forms (-E val, --env val, -E=val, --env=val, and the new -Eval). Edge cases such as -E alone, -E=val, multi-value comma forms, and the run-subcommand boundary are all preserved.

No files require special attention.

Important Files Changed

Filename Overview
src/env.rs Refactors the environment() arg parser to handle -Evalue concatenated short-flag form; logic is correct for all existing and new cases
e2e/cli/test_env_flag_forms Adds four test cases for concatenated short-flag forms (-Edev, -Edev,staging, -Pdev); existing regression tests are preserved

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[arg from iterator] --> B{starts with '-'?}
    B -- No --> C{in_run_subcommand?}
    C -- Yes --> D[break]
    C -- No --> E{is 'run' or 'r'?}
    E -- Yes --> F[set in_run_subcommand = true]
    E -- No --> G[continue]
    B -- Yes --> H{arg in arg_defs?\ne.g. '-E', '--env'}
    H -- Yes --> I[consume next arg as value\n'-E production']
    H -- No --> J{split_at_checked 2\nprefix in arg_defs?\nrest not starts with '='?}
    J -- Yes --> K[push rest as value\n'-Eproduction']
    J -- No --> L{split_once '='\nflag in arg_defs?}
    L -- Yes --> M[push value\n'-E=production' / '--env=production']
    L -- No --> N[ignore arg]
Loading

Reviews (2): Last reviewed commit: "fix(env): parse concatenated short form ..." | Re-trigger Greptile

Comment thread e2e/cli/test_env_flag_forms
Copy link
Copy Markdown
Contributor

@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 adds support for concatenated short-flag forms (e.g., -Eproduction) and includes E2E tests for these new forms. The review feedback suggests simplifying the flag definitions by using arrays instead of HashSet for better efficiency with small static sets. Additionally, a safety issue was identified regarding direct string slicing, which could lead to panics if multi-byte characters are encountered; using safe slicing methods like .get() is recommended to handle character boundaries correctly.

Comment thread src/env.rs Outdated
Comment thread src/env.rs
In the past, mise would correctly parse `-Eval` (vs e.g. `-E val`) such
that `mise.val.toml` would be loaded. Currently `mise -Eval <cmd>`
silently fails to load the `val` environment.

This change re-adds support for this "concatenated short" form to the
parser.

See also PR jdx#8889, which previously fixed support for `--env=val` and
`-E=val` forms.
@bts bts force-pushed the bts/push-tvouvsvunzvx branch from a0e962b to 0e0d39b Compare April 28, 2026 19:15
@jdx jdx enabled auto-merge (squash) April 28, 2026 19:26
@jdx jdx merged commit b217a53 into jdx:main Apr 28, 2026
35 checks passed
mise-en-dev added a commit that referenced this pull request Apr 29, 2026
### 🚀 Features

- **(deps)** add aube provider by @jdx in
[#9452](#9452)
- **(ls-remote)** add strict metadata mode by @jdx in
[#9448](#9448)

### 🐛 Bug Fixes

- **(env)** parse concatenated short form `-Eval` correctly by @bts in
[#9456](#9456)
- **(http)** improve HTML detection by using Content-Type header by
@phateffect in [#9407](#9407)
- **(task)** install monorepo subdir tools before running deps by @jdx
in [#9454](#9454)

### 📦️ Dependency Updates

- update astral-tokio-tar advisory by @jdx in
[#9449](#9449)
- respect -q flag for provider command stream by @JamBalaya56562 in
[#9457](#9457)

### New Contributors

- @JamBalaya56562 made their first contribution in
[#9457](#9457)
- @bts made their first contribution in
[#9456](#9456)
- @phateffect made their first contribution in
[#9407](#9407)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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