Skip to content

Give a Refused Argument Its Own Exit Status in the host-setup/linux Scripts #3605

Done

Description

@ptr727

Problem

Each host-setup/linux script refuses an argument through die, which exits 1. That is the same status a run that failed part way exits with, so a caller cannot tell "the arguments were refused, nothing ran" from "the run started and failed". CODESTYLE.md "Classify a subprocess failure by which command failed and the status code it reports, never by the prose of its message" rules out telling them apart from the ERROR: line.

A downstream wrapper needs that distinction. ptr727/HomeAutomation-Config fetches upgrade-host.sh and install-tools.sh, runs each with every argument it was given, and then runs a step of its own. It brings the agent tools current after an upgrade run, and it queues a tool-check restart after an install run. The maintainer decided on ptr727/HomeAutomation-Config#1466 that the wrapper skips that step where the hub refused its arguments, and still runs it after a real failure, such as a package failure. Today upgrade-host.sh --dryrun, one hyphen short, is refused by the hub, exits 1, and the wrapper upgrades the agent tools for real.

Refusal sites

Every one of these exits 1 today:

  • upgrade-host.sh: an unknown option, and more than one action.
  • install-tools.sh: an unknown option, --repo with no path, more than one action, --json with an action other than --report, --sudo-timestamp with a tool, and an unknown tool name, which resolve_selection refuses after parsing.
  • install-agents.sh: an unknown option, more than one action, --json with an action other than --report, and an unknown tool name.
  • setup-github.sh: an unknown option, --name, --email, or --shared-checkout with no value, and more than one action.
  • install-skills.sh: an unknown option.

Proposal

Give a refused argument an exit status of its own, reserved for it, in every host-setup/linux script, and state it in each script's --help and in CODESTYLE.md "Command-Line Arguments".

  • Refuse through a die_usage (or similar) that exits the reserved status, used at every site above and nowhere else.
  • Reserve the status as well as assigning it. Under set -e a failed command's own status becomes the script's, so a reserved value can still escape from an unrelated failure, such as a grep read error exiting 2. An EXIT trap that maps any other exit carrying the reserved value to 1 keeps the contract whole.
  • 2 matches what argparse exits for a refused argument in the fleet's Python scripts, and 64 is EX_USAGE from sysexits.h. Which one is the hub's call. The trap above is what makes either value safe.

Done

Each script exits the reserved status for every refusal listed above and for no other failure. A test runs each refusal and a failure that would otherwise carry the reserved value, and asserts the status. The status is named in each --help and in "Command-Line Arguments", so a caller reads it as a contract.

Activity

  1. added
    enhancement
    script
    on Oct 29, 2026
  2. ptr727 commented on Nov 1, 2026

    @ptr727
    OwnerAuthor

    Decision needed (decision triage, 2026-11-01)

    Question: When host-setup/linux scripts (upgrade-host.sh, install-tools.sh, install-agents.sh, setup-github.sh, install-skills.sh) refuse an argument through a new die_usage, should the reserved exit status be 2 (argparse parity) or 64 (EX_USAGE)?

    Options, recommended first:

    1. Reserve 64 (EX_USAGE) (recommended): Nothing in the hub uses 64, while 2 already means other things (hub Python returns 2 for non-refusal failures, and grep, diff, and bash builtins exit 2 under set -e), so the EXIT trap would remap a stray 2 far more often, and a caller seeing 64 knows it was a refusal. Unblocks the downstream wrapper decided on HomeAutomation-Config#1466. No work in flight.
    2. Reserve 2 (argparse parity): One number reads like a Python refusal, but the parity is partial (hub Python also exits 2 for non-refusals) and the trap must remap 2 from grep and builtins regularly. Also unblocks HomeAutomation-Config#1466. No work in flight.

    Evidence: Every refusal site uses die, exiting 1 (install-tools.sh:71, upgrade-host.sh:43, install-agents.sh:43, setup-github.sh:58, install-skills.sh:28). No exit 64 or EX_USAGE anywhere. Exit 2 means a non-refusal in scripts/handoff.py:1552-1557, pr_merge.py:166, host_gate.py:576, local_review.py:99 ("2 means the check itself did not run"). CODESTYLE.md "Command-Line Arguments" requires only "a non-zero exit". The maintainer's 2026-10-29 decision on HomeAutomation-Config#1466: wrappers use "the hub's refusal status first".

    Blocks: ptr727/HomeAutomation-Config#1466 (cross-repo)

  3. added
    decision
    on Nov 1, 2026
  4. ptr727 commented on Nov 1, 2026

    @ptr727
    OwnerAuthor

    Maintainer answer (decision triage, 2026-11-01): Option 1: reserve exit status 64 (EX_USAGE) for a die_usage refusal in the host-setup/linux scripts. This unblocks ptr727/HomeAutomation-Config#1466 once it lands. This is now work for the next burndown round.

  5. removed
    decision
    on Nov 1, 2026
  6. ptr727 commented on Nov 23, 2026

    @ptr727
    OwnerAuthor

    Backlog burndown claim (round 5, 2026-11-23): branch burndown/host-setup-usage-exit.

    Predicted files: host-setup/linux/{upgrade-host,install-tools,install-agents,setup-github,install-skills,install-global-rules,install-safety-kit,restore-secrets}.sh, host-setup/linux/README.md, CODESTYLE.md, tests/{test_install_tools,test_install_agents,test_setup_github,test_upgrade_host,test_global_rules,test_restore_secrets,test_cli_usage}.py.

    Group issues: #3605.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions