Skip to content

An empty --shell= value and a bare rtk test answer with an anyhow chain at exit 1, not the promised clap usage error #4290

Open

Description

@KuSh

src/core/shell.rs states the contract in SHELL_ARITY_MESSAGE's own doc: "One rule, one wording: the CLI reports it as a clap usage error before execution." Two ways of misusing these commands still answer with an anyhow chain at exit 1 instead, which is the shape #4125 spent two rounds removing from its other paths.

Found while reviewing #4125, on its head. Neither is a regression that PR introduced — the second is arguably an improvement that went half way — so neither held it.

1. An empty --shell= value

$ rtk err --shell= /bin/true
rtk: Failed to run err command: Failed to prepare err command: shell must not be empty    exit 1
$ rtk test --shell= /bin/true      same, exit 1
$ rtk summary --shell= /bin/true   same, exit 1
$ rtk run --shell= -c 'echo hi'    error: the argument '--shell <SHELL>' cannot be used with '[ARGS]...'   exit 2

run is right only because clap catches a conflict first. Every other --shell misspelling on the three positional surfaces now exits 2 — a missing value, a split script — so this is the last one out of line. The merge-base exited 2 here too.

shell_command's bail!("shell must not be empty") is doing the work clap should: a value_parser rejecting an empty value would move it before execution and make all four consistent.

2. A bare rtk test

$ rtk test
rtk: Failed to run test command: Failed to prepare test command: command is required     exit 1
$ /usr/bin/test ; echo $?        1
$ dash -c 'test' ; echo $?       1

Here the exit code is now correct and the merge-base's was not — it exited 0. rtk test deliberately shadows the POSIX utility, which exits 1 with no arguments, so 1 is the right answer and only the message is wrong: the real test prints nothing. rtk err and rtk summary were fixed by giving their positionals required = true, which test cannot take without losing the POSIX behaviour, so this one wants the bail replaced by a silent 1 rather than a clap error.

Scope note

Both are small and both fail rather than succeeding, which is why they are here and not in that PR. They are grouped because they are one question — which layer answers a misuse — and because fixing them separately would touch the same two functions twice.

Activity

  1. added
    bug
    good first issue
    on Sep 26, 2026
  2. rtk-wshm-sync-bot commented on Sep 26, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟢 Priority low
    🎯 Confidence 85%

    Summary

    --shell= (empty) and bare rtk test still emit anyhow chains at exit 1 instead of clap usage errors / silent exit 1, per the contract in src/core/shell.rs's SHELL_ARITY_MESSAGE.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/core/shell.rs

    Suggested Actions

    1. Replace shell_command's bail!("shell must not be empty") with a clap value_parser rejecting empty --shell values
    2. For bare rtk test, drop the bail! message and just exit 1 silently to match POSIX test's no-arg behavior
    3. Cross-check against fix(cli)!: preserve argv boundaries in generic runners #4125's fixes (required=true on positionals) since this issue says it's the leftover half
    4. Verify rtk run --shell= stays exit 2 via clap's existing conflict detection after the value_parser change

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. JaiPatel713 commented on Sep 26, 2026

    @JaiPatel713

    Hi, I'd like to work on this. I'll cover both cases described here and add tests for the expected exit status/output behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clibuggood first issuepriority:low

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions