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 ¶
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.