minor cleanup
[libremanage.git] / libremanage-uncolor
CommitLineData
a63343a0
AR
1#!/usr/bin/env perl
2## uncolor ? remove terminal escape sequences such as color changes
3## Source: https://unix.stackexchange.com/questions/14684/removing-control-chars-including-console-codes-colours-from-script-output by Gilles
4while (<>) {
5 s/ \e[ #%()*+\-.\/]. |
6 \e\[ [ -?]* [@-~] | # CSI ... Cmd
7 \e\] .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL)
8 \e[P^_] .*? (?:\e\\|\x9c) | # (DCS|PM|APC) ... ST
9 \e. //xg;
10 print;
11}