On Thu, Oct 23, 2025 at 3:29 PM Tim Woodall <[email protected]> wrote: > > On Thu, 23 Oct 2025, Tim Woodall wrote: > > > exec {FDLOCK}>&- > > vs flock -u ${FDLOCK} > > I actually managed to get chatGPT to explain this (eventually). > > The former closes the file, but doesn't release the lock, the lock is > released only when the process exits and the OS determines that it's > safe to release the lock. > > flock -u unconditionally releases the lock. > > > Turns out that closing the FD was the old BSD way of doing it and it's > still habit in a lot of code where it doesn't matter. It's only cases > like mine where the os cleanup gets delayed that the explicit flock -u > is now needed. > > (Also from chatGPT, so may not be correct!)
You might try using Shellcheck. It may flag the use case. Jeff

