Comment by chasil
11 hours ago
Try using the Windows busybox port of "Bash":
https://frippery.org/busybox/index.html
It has a subset of bash implemented on Ash/Dash. Arrays are not supported, but it is quite fast.
The forking problem is still present, though.
Cygwin bash isn't slow either. The problem is a typical bash script isn't a series of bash operations, it's a series of command line program executions.
For example, someone might do something like this (completely ignoring the need to quote in the interests of illustrating the actual issue, forking):
Instead of something like this:
This avoids a sed invocation per loop and eliminates self-renames, but it's harder to work with.
Of course the code as written is completely unusuable in the presence of spaces or other weird characters in filenames, do not use this.
No, seriously, give an ash-derivative a try.
Dash has been benchmarked as 4x faster than bash. The bash manpage ends by stating that "bash is too big, and too slow."