From 975737d71dbe04525dfc48bf46e752fb3d1fd791 Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Sat, 20 Jul 2019 14:21:26 +1000 Subject: [PATCH] tools: Enable color in shellcheck. --- eris/terminal.py | 2 +- eris/termstr.py | 2 +- eris/tools.toml | 3 ++- tests/termstr_test.py | 4 ++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/eris/terminal.py b/eris/terminal.py index f785309..a2b69bd 100644 --- a/eris/terminal.py +++ b/eris/terminal.py @@ -11,7 +11,7 @@ import sys ESC = "\x1b" -normal = "[m" +normal = "[m" # or "[0m" bold = "[1m" italic = "[3m" standout = "[7m" diff --git a/eris/termstr.py b/eris/termstr.py index b3486f8..2a87ba7 100644 --- a/eris/termstr.py +++ b/eris/termstr.py @@ -170,7 +170,7 @@ class TermStr(collections.UserString): end_index = part.index("m") except ValueError: end_index = 0 - if part[:2] == "[m": # Normal + if part[:2] == terminal.normal or part[:3] == "[0m": # Normal is_bold, is_italic, is_underlined = False, False, False fg_color, bg_color = None, None elif part[:3] == terminal.bold: diff --git a/eris/tools.toml b/eris/tools.toml index 1e4a18d..7fea622 100644 --- a/eris/tools.toml +++ b/eris/tools.toml @@ -220,7 +220,8 @@ tools_for_extensions = [ [shellcheck] dependencies = ["shellcheck"] - command = "shellcheck" + command = "shellcheck --color=always" + has_color = true [cppcheck] dependencies = ["cppcheck"] diff --git a/tests/termstr_test.py b/tests/termstr_test.py index 57a9509..803fc4f 100755 --- a/tests/termstr_test.py +++ b/tests/termstr_test.py @@ -144,6 +144,10 @@ class TermStrTests(unittest.TestCase): eris.terminal.ESC + "[mbar"), termstr.TermStr("foo").bg_color(5) + termstr.TermStr("bar")) + self.assertEqual(TermStr.from_term(eris.terminal.ESC + "[45mfoo" + + eris.terminal.ESC + "[0mbar"), + termstr.TermStr("foo").bg_color(5) + + termstr.TermStr("bar")) if __name__ == "__main__":