Skip to content

Interactive prompts abort at EOF instead of cancelling cleanly #42

Description

@PeGa

What happens

Confirmation prompts read with a bare read -r ans under set -euo pipefail. At EOF read returns 1, so the script dies mid-prompt with no message:

$ focus continue < /dev/null
▶ Continue 'demo' (0m before pause)? (Y/n): $ echo $?
1

The prompt line is printed but never completed, nothing explains the exit, and the session is left as it was.

Why it's needed

For reset and import this contradicts a stated convention. CONV-YES:

Destructive ops (reset, import) require the literal word yes; anything else cancels cleanly with exit 0 (cancel ≠ error).

At EOF the script aborts before reaching the [[ "$ans" == "yes" ]] test, so it exits 1 where the contract says 0. It fails in the safe direction — nothing is destroyed — but the exit code says "error" when the correct answer is "cancelled".

There is already a precedent for the fix in the codebase: services/merge.sh uses read -r ans || true and then falls through to its default. The other prompts predate it.

Suggested fix

read -r ans || true at each site, letting the existing default (${ans:-N} / ${ans:-Y} / the yes test) decide — which turns EOF into a clean cancel.

Locations

  • lib/reset.sh:21 and lib/import.sh:34 — the CONV-YES cases
  • lib/continue.sh:20
  • lib/on.sh:35
  • lib/past.sh — the delete branch

Activity

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions