On Fri, Oct 9, 2020 at 1:08 PM Matthew Martin <phy1729@gmail.com> wrote:
A user reported in #zsh they were seeing sporadic zf_mkdir errors when
concurrently creating the same directory. Move the stat ISDIR check to
after the mkdir call to avoid the race.

Er, sorry, this doesn't actually avoid the race, it just prevents the error message from being shown by whichever shell loses the race.

I'm not sure that's really desirable?  Sometimes you might want to know that the directory was NOT created BY the current shell?

On the flip side in the original code we skip the mkdir entirely if the directory already exists, so perhaps this is close enough.

In neither variation are we checking that the existing directory actually has the requested mode.