Skip to content

fix(nanoclaw bootstrap): restore terminal state, don't launch TUI under a pipe - #26

Open
nir-singher-band wants to merge 1 commit into
mainfrom
fix/nanoclaw-bootstrap-tty
Open

fix(nanoclaw bootstrap): restore terminal state, don't launch TUI under a pipe#26
nir-singher-band wants to merge 1 commit into
mainfrom
fix/nanoclaw-bootstrap-tty

Conversation

@nir-singher-band

Copy link
Copy Markdown
Collaborator

What

Two terminal-hygiene fixes in nanoclaw/bootstrap.sh for the curl | bash install path.

Why

1. Terminal left in raw / no-echo state

register-agent.sh prompts for the Band API key with read -s (echo off) on /dev/tty. If the script dies mid-prompt, the terminal stays in that state after the script exits.

  • Save stty -g up front (when /dev/tty is usable) and restore it on EXIT, falling back to stty sane.
  • The registration block's tempfile-cleanup previously ran trap - EXIT after removing the creds file — which would have wiped the restore trap set at the top. Fixed by folding creds cleanup into the trap and re-arming the restore (trap _band_restore_tty EXIT) instead of clearing it.

2. Nested TUI launched from inside the pipe

The handoff did claude /add-band < /dev/tty unconditionally, spawning an interactive Claude TUI that reads /dev/tty while the parent shell is the curl | bash pipe. When stdin isn't a terminal, restore the tty and print instructions to cd in and run claude /add-band from a real prompt instead. When stdin is a terminal, behavior is unchanged (claude /add-band).

Test

  • bash -n clean, shellcheck -S warning clean
  • tests/test_catalog_drift.py: 10 passed, 1 skipped (incl. test_bootstrap_syntax)

Notes

Stacks cleanly on top of #25 (the nanoclaw_setup_done hint) — that hint runs in its own trap-free subshell and is untouched by the new EXIT trap. Parallels the existing fix/hermes-bootstrap-tty work.

🤖 Generated with Claude Code

…er a pipe

Two terminal-hygiene fixes for running under `curl | bash`:

- register-agent.sh prompts for the API key with `read -s` (echo off) on
  /dev/tty. If the script dies mid-prompt the terminal is left in raw /
  no-echo state. Save `stty -g` up front and restore it on EXIT (falling back
  to `stty sane`). The registration block's tempfile-cleanup trap previously
  did `trap - EXIT`, which would have wiped this restore trap — fold the creds
  cleanup into the trap and re-arm the restore instead of clearing it.

- The handoff did `claude /add-band < /dev/tty` unconditionally, spawning a
  nested interactive Claude TUI reading /dev/tty while the parent shell is the
  `curl | bash` pipe. When stdin isn't a terminal, restore the tty and print
  instructions to cd in and run `claude /add-band` from a real prompt instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.

1 participant