A script to quieten LuaLaTeX

This is an example script which shows how to quieten the output of lualatex by running it through a pipe in a Perl script. This is specific to the FreeBSD locations of files, so you may need to edit the regular expression to ignore the files on your operating system.

#!/home/ben/software/install/bin/perl
use warnings;
use strict;
my $ok = GetOptions (
    verbose => \my $verbose,
);
if (! $ok) {
    print <<EOF;
--verbose - debugging mode
EOF
    exit;
}
my $latex = 'lualatex';

my $file = $ARGV[0];
my $ignore = $file;
$ignore =~ s!\.tex!!;
if ($verbose) {
    print "Ignoring $ignore\n";
}
open (my $lfh, '-|',  "$latex @ARGV") or die "Failed to open latex";
while (my $line = <$lfh>) {
    # Discard the huge list of files which appears on each run of the
    # program.
    if ($line =~ m!/usr/local/share/texmf-dist/!) {
        next;
    }
    # Ignore guff like (something.tex etc.
    if ($line =~ m!\((?:\./)?\Q$ignore\E\.!) {
        next;
    }
    # Sometimes the files are cut and only the end appears
    if ($line =~ m!x\)+$!) {
        next;
    }
    # Utterly useless information
    if ($line =~ /
        This\sis\sLuaTeX
    |
        restricted\ssystem\scommands
    |
        For\sadditional\sinformation\son\samsmath
    |
        ASCII\sHyphenation\spatterns\sfor\sBritish\sEnglish
    |
        Define\scommands\sfor\sEnglish\sdate\sformat
    |
        Loading\sMPS\sto\sPDF\sconverter
    |
        isodate:\sbabel\.sty\shas\sbeen\sloaded
    |
        Document\sClass:
    |
        LaTeX2e
    |
        L3\sprogramming\slayer
    /x) {
        next;
    }
    if ($line =~ /^\s*$/) {
        next;
    }
    print $line;
}

# Local Variables:
# mode: perl
# End:

(download)


Copyright © Ben Bullock 2009-2023. All rights reserved. For comments, questions, and corrections, please email Ben Bullock (benkasminbullock@gmail.com) or use the discussion group at Google Groups. / Privacy / Disclaimer