Paul Eggert wrote:
> > +  ln -f "$file" "$file~" 2>/dev/null || cp -f "$file" "$file~" || {
> 
> This will be problematic if the destination already exists, as the 
> resulting permissions etc. may not be what the user intend. How about if 
> we fall back on "mv -f" instead? Although this has the disadvantage of 
> having a small window where "$file" does not exist, I think that's 
> preferable to the disadvantage of using "cp".

How about

  ln -f "$file" "$file~" 2>/dev/null || { rm -f "$file~" && cp "$file" 
"$file~"; } || {

then? It fixes the problem "if the destination already exists", and does
NOT leave a window where "$file" does not exist.

Bruno




Reply via email to