termtext

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: GPL-3.0, LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package termtext makes untrusted text safe to write to a terminal.

Adapted from GSI-HPC/clusterctl internal/output/escape.go; it is meant to be replaced by the shared go-clikit/termtext package once that exists.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeText

func EscapeText(s string) string

EscapeText makes untrusted text safe to write to a terminal, keeping its lines.

An error message can quote what a container, docker or Slurm said, and that is not trusted: a carriage return or a cursor movement can overwrite what was printed before, and an escape sequence can retitle the terminal or write the clipboard. EscapeText replaces every C0 and C1 control character, DEL, the Unicode controls that reorder or break lines, and bytes that are not UTF-8 with a visible escape such as \x1b or \u009b. Newline and tab are kept, since they cannot move the cursor back over text already printed.

Text that holds none of these is returned unchanged.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL