From bd63caed9600a768a82f79bb78c4df9b26f0b0cf Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Tue, 24 May 2016 18:56:38 +0530 Subject: [PATCH] Fix exclude startegy in tools/lister.py. Previously lister.py used to check whether the exclude path is a substring of a path being considered. So it would fail when the exclude path is an absolute path or uses '..' or '.'. --- tools/lister.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/lister.py b/tools/lister.py index a0362f1c62..4802a7f887 100755 --- a/tools/lister.py +++ b/tools/lister.py @@ -1,8 +1,9 @@ #!/usr/bin/env python from __future__ import print_function - from __future__ import absolute_import + import os +from os.path import abspath import sys import subprocess import re @@ -72,9 +73,10 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False, for fpath in files: # this will take a long time if exclude is very large in_exclude = False + absfpath = abspath(fpath) for expath in exclude: - expath = expath.rstrip('/') - if fpath == expath or fpath.startswith(expath + '/'): + expath = abspath(expath.rstrip('/')) + if absfpath == expath or absfpath.startswith(expath + '/'): in_exclude = True if in_exclude: continue