Some little disagreement:-) (Overall, your answer is obviously correct, no doubt about that)
- Strictly speaking, locking $0 has no difference from locking a "separate" file, as $0 is still a separate lock file, not a direct lock on the file under concern itself.
- A caveat with this approach (to lock $0) is that, it adds a restriction that, in order to make the lock work, multiple users have to run a single copy of the script from the same location, which is not true all the time.