Skip to content

Preserving order between separate options (e.g., --include and `--exclude) #761

@adamsmd

Description

@adamsmd

Is there a way to define rsync-style --include and --exclude commands where the order of these commands relative to each other is important? In rsync the first --include or --exclude in the command line that a file matches determines whether the file is included or not.

For example, consider rsync --include=pattern1 --exclude=pattern2 --include=pattern3 --exclude=pattern4.

  • If a file matches pattern1, rsync includes the file.
  • If a file doesn't match pattern1 but matches pattern2, rsync excludes the file.
  • If a file doesn't match pattern1 or pattern2 but matches pattern3, rsync includes the file.
  • If a file doesn't match pattern1, pattern2 or pattern3 but matches pattern4, rsync excludes the file.
  • If a file doesn't match pattern1, pattern2, pattern3 or pattern4, rsync uses some default handling for the file.

If I use a list @Option for --include and a separate list @Option for --exclude, the order between includes and the order between excludes is preserved but not the order between includes and excludes.

If I use a list @Option for both --include and --exclude as names, then the order between includes and excludes is preserved, but I don't see a way to know which were includes and which were excludes.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions