mktemp guaranties to create the STAMPFILE without clobbering other files. However the file gets deleted and manually created with touch in the remove_cmd function, losing it uniqueness guaranties.
This could be fix by calling rm -f "$STAMPFILE" at the end of the script and not remove it in remove_cmd. This also has the benefit of being more performant (since the file is not recreated constantly) and also it ensures that the stamp file is always deleted (even if remove_cmd is not called).
mktemp
guaranties to create theSTAMPFILE
without clobbering other files. However the file gets deleted and manually created withtouch
in theremove_cmd
function, losing it uniqueness guaranties.This could be fix by calling
rm -f "$STAMPFILE"
at the end of the script and not remove it inremove_cmd
. This also has the benefit of being more performant (since the file is not recreated constantly) and also it ensures that the stamp file is always deleted (even ifremove_cmd
is not called).