Skip to content

fix: autodetect color output for pipes#1222

Open
puneetdixit200 wants to merge 1 commit into
blacktop:masterfrom
puneetdixit200:fix/971-auto-disable-color-for-pipes
Open

fix: autodetect color output for pipes#1222
puneetdixit200 wants to merge 1 commit into
blacktop:masterfrom
puneetdixit200:fix/971-auto-disable-color-for-pipes

Conversation

@puneetdixit200
Copy link
Copy Markdown

@puneetdixit200 puneetdixit200 commented May 21, 2026

Summary

Fixes #971.

  • Keep color output in auto mode by default: stdout pipes/files disable ANSI output.
  • Preserve --color as an explicit force-color override.
  • Preserve --no-color / NO_COLOR as explicit force-off behavior.
  • Reuse the same decision helper in ent and notif, which previously reset color.NoColor after root command startup.

Testing

  • go test ./cmd/ipsw/cmd -run TestShouldDisableColor -count=1
  • go test ./cmd/ipsw/cmd ./cmd/ipsw/cmd/dyld ./cmd/ipsw/cmd/macho -count=1
  • make build
  • ./ipsw macho info --arch arm64e /bin/ls > /tmp/ipsw-macho-info-no-color.txt plus an ANSI escape scan of the redirected file: no_ansi

Also ran go test ./... -count=1; it reached the broader suite but failed in existing local-fixture/device-dependent areas: pkg/lzma cannot open data/data.txt, and several pkg/usb/* tests assume an attached device.

AI Assistance

OpenAI GPT-5 helped locate the color-handling paths, draft the patch, and draft this PR text. I reviewed the changed lines and verified the behavior with the commands above.

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.

Color output doesn't get autodetected

1 participant