Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • FYI, that feature was implemented in zsh, ksh93 and bash at the same time following discussion between maintainers of all three shells. IIRC, proposal was by Oliver Kiddle, one of zsh maintainers. Commented Sep 10, 2021 at 11:21
  • In other words, this is a method that you definitely should not use if you like to create portable scripts that work with POSIX shells. Commented Sep 10, 2021 at 11:25
  • 1
    @schily, given how the Q asked for a solution that works in zsh, while presenting one that works in Bash (only), that's hardly a fault in this answer. Also, I don't see your answer with a POSIX-compatible solution either. Commented Sep 10, 2021 at 12:35
  • 1
    In one of the linked questions, there's was a version of this with ( flock -e $fd; ... ) {fd}>/some/lockfile, but for some reason zsh doesn't seem to parse that, even though it supports {var}>whatever on a simple command (or with exec, as here) Commented Sep 10, 2021 at 13:26