Commit a12f765
fix(keepopen): honour NO_COLOR and auto-strip ANSI for non-TTY stdout (#176)
## Summary
`keepopen.sh` always emitted ANSI colour escapes — even when the user
redirected output to a file or pipeline, and even when `NO_COLOR=1`
was set. [no-color.org](https://no-color.org/) has been the canonical
opt-out env var since 2017; respecting it is one of the cheapest UX
wins available.
## Change
At the top of `keepopen.sh`, if either `NO_COLOR` is set OR stdout is
not a TTY, all colour variables become empty strings. Banners and
prefix labels become plain text — still loud and clearly labelled,
just without escapes.
\`\`\`bash
if [[ -n "${NO_COLOR:-}" ]] || [[ ! -t 1 ]]; then
C_RED='' C_YEL='' C_CYA='' C_GRN='' C_BOLD='' C_RST=''
else
# original ANSI definitions
fi
\`\`\`
## Verified
\`\`\`
$ NO_COLOR=1 keepopen.sh testapp /tmp false false | grep -c $'\033'
0
$ keepopen.sh testapp /tmp false false | grep -c $'\033' # piped → not
TTY
0
\`\`\`
Desktop-launch path keeps colour (real terminal, no `NO_COLOR`), so
the on-screen failure banners are unchanged. The new behaviour only
fires when:
- User has `NO_COLOR` set globally (their explicit preference), or
- Output is piped to a file / capture (CI logs, `tee`, `.log`
redirects)
## Scope
Touches `launcher/keepopen.sh` only — not part of the
a2ml↔adoc lock-step group, so the gate in #172 does not fire on this
PR.
## Coordination
Independent of all other open launcher-standard PRs (#170, #171,
#172, #173, #175) — different file, no conflicts in any merge order.
## Test plan
- [x] `NO_COLOR=1` produces zero ANSI escapes
- [x] Pipe (non-TTY stdout) produces zero ANSI escapes
- [x] Default TTY behaviour unchanged (loud red/yellow banners)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b562ba1 commit a12f765
1 file changed
Lines changed: 15 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
47 | 56 | | |
48 | 57 | | |
49 | 58 | | |
| |||
0 commit comments