summaryrefslogtreecommitdiff
path: root/scripts/verify-bashisms
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2017-01-31 13:50:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-31 15:28:35 +0000
commite2dd3621c45e854b4eb054b4d4537487462cdd39 (patch)
tree3bb4d53ff2482229da6de2a93ae320d6f5e5a786 /scripts/verify-bashisms
parentb690b8dc634844b4f6672d524f0e6f1d86dc4e20 (diff)
downloadopenembedded-core-e2dd3621c45e854b4eb054b4d4537487462cdd39.tar.gz
openembedded-core-e2dd3621c45e854b4eb054b4d4537487462cdd39.tar.bz2
openembedded-core-e2dd3621c45e854b4eb054b4d4537487462cdd39.zip
verify-bashisms: support warnings with more than one line of source code
All warnings start with "possible bashism in", followed by one or more (in the case of line continuation) lines of source code. To support more than one line, we now split by matching against the known intro text. Example: $ verify-bashisms guile ... /.../openembedded-core/meta/recipes-devtools/guile/guile_2.0.13.bb possible bashism in guile_cross_config line 94 ($'...' should be "$(printf '...')"): echo '#!'`which ${BUILD_SYS}-guile`$' \\\n--no-auto-compile -e main -s\n!#\n(define %guile-build-info '\'\( \ > ${B}/guile-config.cross Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/verify-bashisms')
-rwxr-xr-xscripts/verify-bashisms21
1 files changed, 15 insertions, 6 deletions
diff --git a/scripts/verify-bashisms b/scripts/verify-bashisms
index 7283980ed5..dab64ef501 100755
--- a/scripts/verify-bashisms
+++ b/scripts/verify-bashisms
@@ -23,6 +23,7 @@ def is_whitelisted(s):
return False
SCRIPT_LINENO_RE = re.compile(r' line (\d+) ')
+BASHISM_WARNING = re.compile(r'^(possible bashism in.*)$', re.MULTILINE)
def process(filename, function, lineno, script):
import tempfile
@@ -42,11 +43,18 @@ def process(filename, function, lineno, script):
# TODO check exit code is 1
# Replace the temporary filename with the function and split it
- output = e.output.replace(fn.name, function).splitlines()
- if len(output) % 2 != 0:
- print("Unexpected output from checkbashism: %s" % str(output))
- return
-
+ output = e.output.replace(fn.name, function)
+ if not output or not output.startswith('possible bashism'):
+ # Probably starts with or contains only warnings. Dump verbatim
+ # with one space indention. Can't do the splitting and whitelist
+ # checking below.
+ return '\n'.join([filename,
+ ' Unexpected output from checkbashisms.pl'] +
+ [' ' + x for x in output.splitlines()])
+
+ # We know that the first line matches and that therefore the first
+ # list entry will be empty - skip it.
+ output = BASHISM_WARNING.split(output)[1:]
# Turn the output into a single string like this:
# /.../foobar.bb
# possible bashism in updatercd_postrm line 2 (type):
@@ -60,7 +68,8 @@ def process(filename, function, lineno, script):
if lineno is not None:
message = SCRIPT_LINENO_RE.sub(lambda m: ' line %d ' % (int(m.group(1)) + int(lineno) - 1),
message)
- result.extend([' ' + message, ' ' + source])
+ result.append(' ' + message.strip())
+ result.extend([' %s' % x for x in source.splitlines()])
if result:
result.insert(0, filename)
return '\n'.join(result)