Browse code

add ability to ignore rules in bash8

Change-Id: Ia6472f4bb251bf3e9846e08e30b2f9ea30ea1c03

Sean Dague authored on 2014/02/03 08:49:30
Showing 1 changed files
... ...
@@ -30,8 +30,18 @@ import fileinput
30 30
 import re
31 31
 import sys
32 32
 
33
-
34 33
 ERRORS = 0
34
+IGNORE = None
35
+
36
+
37
+def register_ignores(ignores):
38
+    global IGNORE
39
+    if ignores:
40
+        IGNORE='^(' + '|'.join(ignores.split(',')) + ')'
41
+
42
+
43
+def should_ignore(error):
44
+    return IGNORE and re.search(IGNORE, error)
35 45
 
36 46
 
37 47
 def print_error(error, line):
... ...
@@ -97,11 +107,13 @@ def get_options():
97 97
         description='A bash script style checker')
98 98
     parser.add_argument('files', metavar='file', nargs='+',
99 99
                         help='files to scan for errors')
100
+    parser.add_argument('-i', '--ignore', help='Rules to ignore')
100 101
     return parser.parse_args()
101 102
 
102 103
 
103 104
 def main():
104 105
     opts = get_options()
106
+    register_ignores(opts.ignore)
105 107
     check_files(opts.files)
106 108
 
107 109
     if ERRORS > 0: