4 ms·
You don't have to choose glob&loop or find&xargs as a zsh user, as there is a built-in zargs function: zargs -- $crazy_glob -- $command Much like the `find
by JNRowe 6y ago
You don't have to choose glob&loop or find&xargs as a zsh user, as there is a built-in zargs function:
zargs -- $crazy_glob -- $command
Much like the `find | xargs` version you can begin with `zargs -- $glob` until your filter is correct and then tack the command on when you're ready.
Hmm, now I really like the idea of an oil-y version of this where you could do something like `oargs { $clearer_glob_DSL } { $command_block }`. It might even be possible right now using stest from dmenu¹ as a stand-in for a more advanced globbing alternative.
I believe part of the reason zsh users find the extended globbing functionality useful is the basic usage matches their expectations with other tools, unlike find's quirky syntax. The common filters use the same values as you'd see in `ls --classify` output. For example, you want executable files tack a `*` on or for sockets use a `=`.
FWIW, the find comparison isn't quite right. Out of the box `**/file` wouldn't traverse a .git directory anyway, unless the GLOB_DOTS option is set or you provide the equivalent flag as in `**/file(D)`. The less specific point is quite true though as adding negation and toggling flags in a single glob can be extremely difficult to read. See the examples at the bottom of zshexpn(1) for proof of that.
Edit to add: I hope this comes across as an attempt to be helpful as was intended, and not some awful stop motion attempt.
¹ https://tools.suckless.org/dmenu/ https://tools.suckless.org/dmenu/