fix: strip all ANSI escape sequences in terminal command output#838
Open
OmarAlaaeldein wants to merge 1 commit into
Open
fix: strip all ANSI escape sequences in terminal command output#838OmarAlaaeldein wants to merge 1 commit into
OmarAlaaeldein wants to merge 1 commit into
Conversation
When sudo (or other interactive programs) run via run_terminal_command, they can emit cursor-movement, scroll-region, alternate-screen and other VT/ANSI control sequences that bleed into the TUI and corrupt the display (garbage characters, broken scrolling). Changes: - Switch stripColors -> stripAnsi so ALL escape sequences are removed from captured stdout/stderr, not just SGR color codes (\x1B[...m). - Strip bare \r characters that sudo uses to erase its password-prompt line after credentials are accepted. - Set SUDO_PROMPT to a plain ASCII string so sudo never emits decorated (colored/formatted) prompts to /dev/tty. - Default TERM=dumb (when not overridden by the caller) so child programs like git, less, and man suppress their own color/cursor output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes TUI display and scroll corruption when running sudo or interactive commands.
stripColorstostripAnsiinrun-terminal-command.tsto strip all VT/ANSI control codes (e.g. cursor movement, alternate screen).\r(carriage return) characters.SUDO_PROMPTto a plain text string to prevent sudo from emitting decorated prompts.TERM=dumbfor child processes to suppress color/cursor escape sequences.