Skip to content

fix(task): skip shebang line in displayed task command#9844

Merged
jdx merged 5 commits into
mainfrom
claude/youthful-varahamihira-d06f43
May 13, 2026
Merged

fix(task): skip shebang line in displayed task command#9844
jdx merged 5 commits into
mainfrom
claude/youthful-varahamihira-d06f43

Conversation

@jdx

@jdx jdx commented May 13, 2026

Copy link
Copy Markdown
Owner

Summary

When a task's run body starts with a shebang (e.g. #!/usr/bin/env bash) and/or shell-option lines like set -Eeuo pipefail, the command echo ends up showing only that boilerplate:

[generate-completions] $ #!/usr/bin/env bash

That's the only thing the user sees for the entire task — every following line of the body is hidden because trunc keeps just the first line of the displayed command, and for these scripts the first line is boilerplate.

This PR skips leading shebang, blank, and set ... lines when building the displayed command, so the first real command shows up. Execution is unchanged — the script (shebang and all) is still written to the temp file and run normally.

Before / after

# before
[generate-completions] $ #!/usr/bin/env bash

# after
[generate-completions] $ fzf --fish > ~/.config/fish/completions/fzf.fish

Verified locally across several variants:

[repro] $ echo "real command"                  # was: #!/usr/bin/env bash
[with-shebang] $ echo "after set -e"           # shebang + set skipped
[set-without-shebang] $ echo "after set"       # bare set skipped
[shebang-only] $ echo "after blank line"       # blank line skipped
[no-skip] $ echo 'simple one-liner'            # unchanged

Fixes #9842.

Test plan

  • cargo build — clean
  • cargo test --bin mise task:: — 124 task unit tests pass
  • Manual smoke test across shebang, set, blank-line, and plain variants

🤖 Generated with Claude Code


Note

Low Risk
Low risk: changes only affect how inline task scripts are displayed (echoed) before execution, not how they run. Main risk is minor formatting edge cases for empty scripts/args.

Overview
Task command echoing for inline run scripts now skips leading boilerplate (blank lines, shebangs, and set ...) so the first real command is shown instead of just the header.

The displayed $ ... string construction was adjusted to handle empty script/argument combinations without producing awkward output; execution behavior remains unchanged.

Reviewed by Cursor Bugbot for commit eb6e59a. Bugbot is set up for automated code reviews on this repo. Configure here.

When a task's `run` value starts with a shebang (e.g. `#!/usr/bin/env bash`),
mise echoes the command being run as `[task] $ <first line>`, which for
shebang scripts ended up showing `[task] $ #!/usr/bin/env bash` instead of
something useful. Strip the shebang line for display so the first actual
command appears; execution is unchanged.

Fixes #9842.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

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

Copy link
Copy Markdown
Contributor

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 modifies the TaskExecutor to improve command display by stripping leading shebangs from scripts, ensuring users see the actual command content. A review comment identifies a redundant .to_string() call on the result of the format! macro, which should be removed to avoid unnecessary allocations.

Comment thread src/task/task_executor.rs Outdated
@greptile-apps

greptile-apps Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the task command echo so that scripts starting with shebang or set boilerplate show the first meaningful line instead of e.g. #!/usr/bin/env bash. Execution is unaffected — only the string passed to trunc / ebold for display changes.

  • The find iterator skips leading empty, #!, bare-set, and set … lines to surface the first real command for display.
  • A four-branch match on (display_script.is_empty(), args_str.is_empty()) replaces the old single format!, correctly eliminating the double-space that appeared when display_script was empty (addressed in a prior fix commit).

Confidence Score: 5/5

Safe to merge — the change is purely cosmetic, touching only how the echoed command string is built for display; the script written to disk and executed is unchanged.

The diff is small and self-contained: a single find iterator that skips boilerplate header lines, and a match to avoid producing a double-space when the filtered result is empty. The trunc call downstream already takes only msg.lines().next(), so multi-line edge cases in display_script are naturally truncated. Execution behaviour — temp-file writing, shebang detection, program dispatch — is completely untouched.

No files require special attention.

Important Files Changed

Filename Overview
src/task/task_executor.rs Adds a display_script filter in exec_script that skips leading blank, shebang, and set ... lines before building the echoed $ … command; execution path is unchanged.

Reviews (5): Last reviewed commit: "style(task): apply cargo fmt" | Re-trigger Greptile

Comment thread src/task/task_executor.rs Outdated
jdx and others added 3 commits May 13, 2026 14:36
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`set -Eeuo pipefail` and similar shell-options lines aren't useful to
echo as the task's "command" either — skip them along with the shebang
so the displayed line is the first real command in the script.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… empty

If a script is entirely shebang/blank/`set ...` lines, `display_script`
ends up empty, which previously produced "$  arg1 arg2" (double space)
when args were present. Join only the non-empty parts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.5.7 x -- echo 18.5 ± 0.8 16.7 22.8 1.00
mise x -- echo 18.9 ± 1.2 16.8 23.8 1.03 ± 0.08

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.5.7 env 18.3 ± 0.8 16.8 22.2 1.00
mise env 18.4 ± 0.8 16.7 23.2 1.00 ± 0.06

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.5.7 hook-env 19.4 ± 0.9 17.6 23.2 1.00
mise hook-env 19.4 ± 0.9 17.6 23.5 1.00 ± 0.07

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.5.7 ls 15.7 ± 0.8 14.1 19.3 1.00
mise ls 15.9 ± 0.8 14.3 19.5 1.02 ± 0.07

xtasks/test/perf

Command mise-2026.5.7 mise Variance
install (cached) 121ms 124ms -2%
ls (cached) 55ms 55ms +0%
bin-paths (cached) 62ms 63ms -1%
task-ls (cached) 481ms 480ms +0%

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jdx jdx merged commit 9919914 into main May 13, 2026
33 checks passed
@jdx jdx deleted the claude/youthful-varahamihira-d06f43 branch May 13, 2026 20:29
3PeatVR pushed a commit to 3PeatVR/mise that referenced this pull request May 14, 2026
## Summary

When a task's `run` body starts with a shebang (e.g. `#!/usr/bin/env
bash`) and/or shell-option lines like `set -Eeuo pipefail`, the command
echo ends up showing only that boilerplate:

```
[generate-completions] $ #!/usr/bin/env bash
```

That's the only thing the user sees for the entire task — every
following line of the body is hidden because
[`trunc`](src/task/task_output.rs:33) keeps just the first line of the
displayed command, and for these scripts the first line is boilerplate.

This PR skips leading shebang, blank, and `set ...` lines when building
the displayed command, so the first real command shows up. Execution is
unchanged — the script (shebang and all) is still written to the temp
file and run normally.

### Before / after

```
# before
[generate-completions] $ #!/usr/bin/env bash

# after
[generate-completions] $ fzf --fish > ~/.config/fish/completions/fzf.fish
```

Verified locally across several variants:

```
[repro] $ echo "real command"                  # was: #!/usr/bin/env bash
[with-shebang] $ echo "after set -e"           # shebang + set skipped
[set-without-shebang] $ echo "after set"       # bare set skipped
[shebang-only] $ echo "after blank line"       # blank line skipped
[no-skip] $ echo 'simple one-liner'            # unchanged
```

Fixes jdx#9842.

## Test plan

- [x] `cargo build` — clean
- [x] `cargo test --bin mise task::` — 124 task unit tests pass
- [x] Manual smoke test across shebang, set, blank-line, and plain
variants

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: changes only affect how inline task scripts are *displayed*
(echoed) before execution, not how they run. Main risk is minor
formatting edge cases for empty scripts/args.
> 
> **Overview**
> Task command echoing for inline `run` scripts now **skips leading
boilerplate** (blank lines, shebangs, and `set ...`) so the first *real*
command is shown instead of just the header.
> 
> The displayed `$ ...` string construction was adjusted to handle empty
script/argument combinations without producing awkward output; execution
behavior remains unchanged.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
eb6e59a. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mise-en-dev added a commit that referenced this pull request May 14, 2026
### 🚀 Features

- **(patrons)** add `mise patrons` command by @jdx in
[#9841](#9841)

### 🐛 Bug Fixes

- **(task)** skip shebang line in displayed task command by @jdx in
[#9844](#9844)

### 🚜 Refactor

- **(security)** switch to sigstore-rust verification by @jdx in
[#9260](#9260)
@thernstig

Copy link
Copy Markdown
Contributor

@jdx I think it would have been good if it did something else than just printing the first line on multi-line run bodies.

Options:

  1. Print the description only
  2. Print the first command, but also print something indicating that there are more lines executed than just the first command.

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