Skip to content

Colors library colorizes unconditionally #127

@wolfgang42

Description

@wolfgang42

Right now, the colors library is just some functions that wrap their arguments in ANSI escape codes. Unfortunately, this means that it always outputs escape codes, even when situations where this is unsuitable, such as when redirecting to files or using a terminal that doesn't understand escapes. The usual convention is to check for these sorts of situations and turn colorization off (optionally with a flag to override the auto-detection).

I haven't looked into the details of what the standard check entails, I think it involves checking isatty and then consulting terminfo/termcap, or possibly just getting the correct escape code directly with tput. Probably some thought needs to be put into optimizing this to avoid causing performance problems by extraneous calls to the relevant programs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    standard libraryIssues or additions to Bashly standard library

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions