import fnmatch


def filename_match(filename, patterns, default=True):
    """Check if patterns contains a pattern that matches filename.

    If patterns is not specified, this always returns True.
    """
    if not patterns:
        return default
    return any(fnmatch.fnmatch(filename, pattern) for pattern in patterns)