From 943d79b73fa9e8b183ac6e2a69d8d9165efa2e18 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sat, 13 Oct 2018 23:00:02 +0200 Subject: [PATCH] Turn absolute paths in warnings/errors into relative ones. For Bazel LaTeX, we store a copy of the texmf into the build environment. The path of the build environment may be relatively long and contain some randomness, depending on the build environment. Turn such paths into relative ones, based on the current working directory to make output more readable. --- latexrun | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/latexrun b/latexrun index b669d9f..cb6ce2d 100755 --- a/latexrun +++ b/latexrun @@ -457,10 +457,12 @@ class Message(collections.namedtuple( 'Message', 'typ filename lineno msg')): def emit(self): if self.filename: - if self.filename.startswith('./'): - finfo = self.filename[2:] - else: + cwd = os.getcwd() + if (os.path.isabs(self.filename) and + os.path.commonpath([self.filename, cwd]) != cwd): finfo = self.filename + else: + finfo = os.path.relpath(self.filename, cwd) else: finfo = '' if self.lineno is not None: