Skip to content

use tput or similar #247

Open
Open
@antonio-gg-dev

Description

@antonio-gg-dev

Using tput instead of direct ANSI escape sequences for changing text and background colors offers several advantages:

  • Portability: tput adapts to different terminal capabilities using the terminfo database, ensuring scripts work across various terminals.
  • Readability: Commands with tput are more descriptive, making the code easier to understand and maintain.
  • Flexibility: tput provides access to a wide range of terminal functions beyond color changes, like cursor movement and screen clearing.
  • Safety: Relying on terminfo reduces the risk of injecting harmful or incorrect escape sequences.
  • Adaptability: tput adjusts to the terminal's supported features, preventing unexpected output in terminals that don't support certain colors or effects.

In summary, tput offers a safer, more portable, and maintainable solution for terminal manipulation than hard-coding ANSI escape sequences.

But not everything that glitters is gold; in PR #245, we saw that a large number of tests failed or became inconsistent across different environments, which really makes us reconsider how to implement these kinds of tools. Therefore, we need to study whether we want to use tput or some alternative and how to do so in a way that does not reduce the reliability of bashunit.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions