Oh my! That `||` is gorgeous. I hadn't seen that before.
This usage is commonly found in other places than the shell, like JavaScript, Perl, and PHP.
some_cmd >foo.tmp && mv foo.tmp foo
The mv will do an atomic rename(), so that you either get the fully formed contents, or nothing at all.Your mechanism is clearly safer, but the user is required to clean up `foo.tmp` themselves in case of failure, so it's not really comparable.