Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC - DO NOT MERGE. Add some sort options. #74

Closed

Conversation

markus-oberhumer
Copy link
Contributor

This commit is meant to help examining path traversal and print order,
and to allow playing around with the flags listed below.

Unfortunately the docs are pretty scarce on this topic.

GOAL: find out how these flags interact with each other, and
add some nice test-cases that also serve as documentation

bfs offers some strategy flags:
-S bfs breadth-first - default
-S dfs depth-first - like find(1)
-S ids ???
-S eds ???

bfs offers some depth flags:
-d POST_ORDER => how does this interact with strategy ?

bfs offers some sort flags:
-s sort entries by name (using strcoll)
-sort-strcmp NEW: this is useful when you cannot use LC_ALL=C
-sort-df NEW: sort directory entries first
-sort-dl NEW: sort directory entries last

This commit is meant to help examining path traversal and print order,
and to allow playing around with the flags listed below.

Unfortunately the docs are pretty scarce on this topic.

GOAL: find out how these flags interact with each other, and
add some nice test-cases that also serve as documentation

bfs offers some strategy flags:
  -S bfs  breadth-first - default
  -S dfs  depth-first - like find(1)
  -S ids  ???
  -S eds  ???

bfs offers some depth flags:
  -d       POST_ORDER => how does this interact with strategy ?

bfs offers some sort flags:
  -s             sort entries by name (using strcoll)
  -sort-strcmp   NEW: this is useful when you cannot use LC_ALL=C
  -sort-df       NEW: sort directory entries first
  -sort-dl       NEW: sort directory entries last
@markus-oberhumer
Copy link
Contributor Author

Hi,

this is NOT meant for merging, but intended as a starting point for discussion on improving the docs on traversal & print ordering.

~Markus

@tavianator tavianator marked this pull request as draft April 16, 2021 12:38
@tavianator
Copy link
Owner

tavianator commented Apr 16, 2021

Related to #58

-S ids ???

Iterative deepening search. Same order as -S bfs, less memory use, but much slower. Potentially useful for gigantic directory trees that bloat the memory use if you still need breadth-first order.

-S eds ???

Exponential deepening search. Like IDS, but rather than [0, 1), [1, 2), [2, 3) etc., it's [0, 1), [1, 2), [2, 4), [4, 8), etc. Has many of the benefits of breadth-first ordering, but with depth-first memory use.

-d POST_ORDER => how does this interact with strategy ?

Most strategies do directories in post order with -d set, and non-directories in regular order. For -S dfs -d, it's the same as find -d. The exception is -S ids -d, which actually does the whole tree bottom to top.

-sort-strcmp NEW: this is useful when you cannot use LC_ALL=C

You can probably achieve this result with LC_COLLATE=C, but anyway I don't mind having a flag to do non-locale comparisons. Might be nice for things like -name '*' too which will fail to match "invalid" filenames in some locales.

@tavianator tavianator closed this Aug 15, 2022
@markus-oberhumer markus-oberhumer deleted the test-sorting branch August 16, 2022 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants