conserve icon indicating copy to clipboard operation
conserve copied to clipboard

`ls --exclude` doesn't exclude the contents of excluded subdirectories

Open sourcefrog opened this issue 4 years ago • 0 comments

For example:

ls ARCHIVE --exclude /.bundle |less

still prints filenames inside the /.bundle directory.

The cause is: traversal in a stored tree does not need to specifically descend into directories to visit their children, and the children do not necessarily match the exclusion path.

There is a workaround: change the globs so that they do match the children, e.g. /.bundle/**.

The same bug probably affects diff and restore.

There are a couple of possibilities:

  1. Remember directories that have been excluded, and skip their children later. If there are ever a lot of them (which might be unlikely) this would be a bit inefficient though.
  2. When building globsets rewrite every glob (not ending in /**) to also match children of a directory with that name.

sourcefrog avatar Jun 01 '21 00:06 sourcefrog