bfs
bfs copied to clipboard
RFC - DO NOT MERGE. Add some sort options.
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
Hi,
this is NOT meant for merging, but intended as a starting point for discussion on improving the docs on traversal & print ordering.
~Markus
Related to https://github.com/tavianator/bfs/issues/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.