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):
for x in *; do
new_name=$(echo $x | sed 's/old/new/')
mv $x $new_name
done
Instead of something like this:
for x in *; do
echo $x
done | sed -r 's|(.*)old(.*)|mv \1old\2 \1new\2|' | grep '^mv ' | bash
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.
To solve the problem or because you saw "slow" and "bash" and wanted to bring up something cool but unrelated?
If I go from 10 seconds of forking and .04 seconds of shell to 10 seconds of forking and .01 seconds of shell, I don't actually care about how cool and fast the shell is. And I've never had the speed of bash itself be a problem.
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.