Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--no-strip-ansi prints ANSI codes and garbles output #785

Open
srithon opened this issue Dec 18, 2024 · 0 comments
Open

--no-strip-ansi prints ANSI codes and garbles output #785

srithon opened this issue Dec 18, 2024 · 0 comments

Comments

@srithon
Copy link
Contributor

srithon commented Dec 18, 2024

This flag was introduced in PR #784, after a commit in PR #739 unconditionally stripped ANSI codes from stdin. PR #739 was made in response to issue #689; in order to prevent the display from being garbled by incorrect ANSI code handling, we opted to simply strip ANSI codes from the input entirely. The implementation in PR #784 (and my own draft implementation in PR #782) simply undo that stripping behavior without addressing the underlying issues from #689, resulting in strange outputs in certain cases. Below is a minimal example which results in garbled output on my machine in Kitty, Alacritty and st.

#!/bin/sh

green=$(tput setaf 2)
reset=$(tput sgr0)

{
  echo "Option 1"
  echo "Option 2"
  echo "${green}Option 3${reset}"
} | gum filter --no-strip-ansi

Here are recordings for each tested terminal. Note that Kitty was a lot worse than the others; interestingly, when I tried using asciinema to record Kitty's output, the recording showed the same 2m result as the other terminals; to show what it actually looked like on-screen I had to use a screen recording.

  1. Kitty
  2. Alacritty
  3. st
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

No branches or pull requests

1 participant