Previously - in the existence of other ANSI escape sequences - the
script deleted text due to the too broad regex. For example in:
foo^[[K bar m
everything behind `foo` was deleted. Thus, only remove SGR sequences by
only matching the spec-allowed bytes.
10 lines
247 B
Sed
Executable File
10 lines
247 B
Sed
Executable File
#!/bin/sed -f
|
||
# SPDX-License-Identifier: MIT
|
||
# Copyright (c) 2025 Julian Prein
|
||
#
|
||
# Remove ANSI SGR (Select Graphic Rendition) escape sequences, e.g. setting
|
||
# color or bold font.
|
||
|
||
# TODO: Why is the range `[0-?]` invalid?
|
||
s/\[[0-9:-?]*[ -/]*m//g
|