Thread (1 message) 1 message, 1 author, 2021-03-29

Re: [PATCH v2 3/5] Makefile: don't needlessly "rm $@ $@+" before "mv $@+ $@"

From: Junio C Hamano <hidden>
Date: 2021-03-29 18:46:49

Ævar Arnfjörð Bjarmason  [off-list ref] writes:
    rm -f thing thing+
    prepare contents for thing >thing+
    mv thing+ thing
...
But I think guarding against "mv" failing is a step too far in
paranoia,...
If mv fails the $(MAKE) rule would fail, so it is OK.  It may leave
thing+ behind, but there is no reason to expect why you would be
able to rm it the next time, so from that point of view, it is OK to
drop the first "rm -f thing+", I would think.  The only case I can
thing of that would help is when you are sharing the working tree
with your team member, the directories are writable to both of you,
but somehow the other person creates thing+ with 0644 or 0755 mode
bits.  You cannot redirect into thing+ the other person left behind,
but you can "rm -f thing+ && cmd >$thing+" (or "cmd -o $thing+") in
such a situation, and that is probably where the pattern comes from
---i.e. simple hygiene.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help