Skip to content

Bug in find conditional for tests/pyo/pyc deletion #212

Description

@edmorley

The find command here aims to delete unwanted files:

&& find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' + \

However the inner conditionals used are of form:
-type d -a -name test -o -name tests
and
-type f -a -name '*.pyc' -o -name '*.pyo'

And the find man page says:

Please note that -a when specified implicitly (for example by two tests appearing without an
explicit operator between them) or explicitly has higher precedence than -o. This means that
find . -name afile -o -name bfile -print will never print afile.

...therefore they are interpreted like:
(-type d -a -name test) -o -name tests
and
(-type f -a -name '*.pyc') -o -name '*.pyo'

...which is presumably not what was intended.

I'll open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions