Attached is bashbug.sh which shows a strange bug in bash - with workaround. The problem seems to be that certain redirections are not closed in-time, leading to a possible exhaustion of file descriptors when doing this redirection in a loop. The strange thing about this is, that the file descriptors are closed later, when it is already too late. There is a workaround, this is to close the redirection manually. However technically this is wrong, as at the time of the close the redirection is no more in effect. Possibly this is an upstream problem, I did not test it.
I saw a similar crash here, where bash would start failing around about
500 iterations in such a loop:
```
export GIT_ASKPASS=echo
grep -v '^#' ../gitolite2gitlab.txt |while read gitolite_path gitlab_path; do
gitolite_url=/srv/git.torproject.org/repositories/$gitolite_path.git
gitlab_url=https://gitlab.torproject.org/$gitlab_path.git
echo "diff -u $gitolite_url $gitlab_url"
diff -u <(git ls-remote $gitolite_url) <(git ls-remote $gitlab_url)
done | tee final-remote-diff.patch
```
~500 is not a random number. it's about half of 1024, which i suspect is
the fd limit i'm hitting. i'm betting the shell is just not closing
those file descriptor at all after the pipeline completes.
normally, i would expect the FD to close after the `diff -u` command
returns there, but it seems that's just not happening.