From: Zac Medico Date: Fri, 14 Nov 2008 21:59:56 +0000 (-0000) Subject: Make the EbuildQuote check filter out matches that appear to be an argument X-Git-Tag: v2.1.6_rc1~72 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b2f0fd4d04da5e74a4f8e770b8b1a61982cacab6;p=portage.git Make the EbuildQuote check filter out matches that appear to be an argument to a message command. For example: false || ewarn "foo $WORKDIR/bar baz" Thanks to Diego 'Flameeyes' Pettenò for reporting this issue (currently triggered by ruby-prof-0.7.0.ebuild). (trunk r11913) svn path=/main/branches/2.1.6/; revision=11914 --- diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index dd81d8716..c9415b759 100644 --- a/pym/repoman/checks.py +++ b/pym/repoman/checks.py @@ -83,8 +83,11 @@ class EbuildQuote(LineCheck): """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc...""" repoman_check_name = 'ebuild.minorsyn' - _ignored_commands = ["echo", "local", "export"] - _ignored_commands += ["eerror", "einfo", "elog", "eqawarn", "ewarn"] + _message_commands = ["die", "echo", "eerror", + "einfo", "elog", "eqawarn", "ewarn"] + _message_re = re.compile(r'\s(' + "|".join(_message_commands) + \ + r')\s+"[^"]*"\s*$') + _ignored_commands = ["local", "export"] + _message_commands ignore_line = re.compile(r'(^$)|(^\s*#.*)|(^\s*\w+=.*)' + \ r'|(^\s*(' + "|".join(_ignored_commands) + r')\s+)') var_names = ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"] @@ -125,6 +128,15 @@ class EbuildQuote(LineCheck): if self.var_reference.search(group) is None: continue + # Filter matches that appear to be an + # argument to a message command. + # For example: false || ewarn "foo $WORKDIR/bar baz" + message_match = self._message_re.search(line) + if message_match is not None and \ + message_match.start() < pos and \ + message_match.end() > pos: + break + # This is an attempt to avoid false positives without getting # too complex, while possibly allowing some (hopefully # unlikely) violations to slip through. We just assume