From 0656e12d6819f6dee671dd6200b2d0895e716c2c Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 3 Feb 2014 08:49:30 +0900 Subject: [PATCH] add ability to ignore rules in bash8 Change-Id: Ia6472f4bb251bf3e9846e08e30b2f9ea30ea1c03 --- tools/bash8.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/bash8.py b/tools/bash8.py index edf7da4645..2623358182 100755 --- a/tools/bash8.py +++ b/tools/bash8.py @@ -30,8 +30,18 @@ import fileinput import re import sys - ERRORS = 0 +IGNORE = None + + +def register_ignores(ignores): + global IGNORE + if ignores: + IGNORE='^(' + '|'.join(ignores.split(',')) + ')' + + +def should_ignore(error): + return IGNORE and re.search(IGNORE, error) def print_error(error, line): @@ -97,11 +107,13 @@ def get_options(): description='A bash script style checker') parser.add_argument('files', metavar='file', nargs='+', help='files to scan for errors') + parser.add_argument('-i', '--ignore', help='Rules to ignore') return parser.parse_args() def main(): opts = get_options() + register_ignores(opts.ignore) check_files(opts.files) if ERRORS > 0: