#!/usr/bin/env perl

use Modern::Perl;
use Pod::Usage;
use vars qw($VERSION $name);

$name = qq(sansi);
$VERSION = qq(\tv.1.0.2\n);

pod2usage("\t$name $VERSION\n\t# # #\t$name:  Not enough arguments were given \t# # #") if ((@ARGV <= 1) && (-t STDIN));
binmode STDIN, ":raw:eol(LF)";
while (<STDIN>) {
    s/\033[^m]*m//g;
    print $_;
}
__END__


=pod

=encoding utf8

=head1 NAME

sansi -- StripANSI; strip ANSI escape sequences/characters from text
files

=head1 SYNOPSIS

B<	sansi> < ANSIfied_textfile > unANSIfied_textfile

Strips ANSI from B<ANSIfied_textfile>. Where B<ANSIfied_textfile> is
the name of the textfile containing ANSI, and B<unANSIfied_textfile>
is a filehandle you've chosen for it's output (sansi redirects the
filtered output to the filename you've chosen).

=head1 DESCRIPTION

B<sansi> was written to strip the ANSI control sequences in files, or
output, often, but not limited to those generated by compilers. I
found it difficult to visually grope/grep the output of script(1)
sessions. Especially with the advent of clang. While it's nice to
replay the script(1) sessions to view the highlighted messages. It's
near impossible to read it inline in your favorite pager, or text
editor; Enter sansi.

=head2 ACKNOWLEDGEMENTS

John Marino.

It probably would have never occurred to me to release
this, except that I thought it might help him, and the other
committers. I hoped it might help him after all the [unintentional]
grief I've caused him. Thanks for your patience, John!

=head1 BUGS

Doubtful. But who knows?

=head1 TODO

Better ARG handling / filtering (sanity checking)

Add additional filters, and switches to match them.

=head1 SEE ALSO

I<>
I<>
I<>

=head1 COPYRIGHT

Copyright 2017, Chris Hutchinson, taint, portmaster

This script is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, or under the BSD2CLAUSE license,
at your choice.

=head1 AUTHOR

Chris Hutchinson, C<portmaster AT bsdforge.com>

=head1 VERSION

Current Revision:  $Revision: 1.0.2 $
Last Modification: $Date: 2017-03-09 18:56:45 $

=cut

