"Philip Rowlands" <[email protected]> writes:

> Would it be worthwhile having an option e.g. --no-clobber=fail to
> modify the exit status when mv didn't perform the rename?
>
> I haven't thought too hard about the semantics of moving a bunch of
> files to a target directory, but we  presumably have to deal with this
> today for -i / -b.
>
> The use case is simply race-free renames. Imagine all the locking
> schemes you could implement with mv(1)!

Does flock(1) not work for your use case [1]? That is what I would use
if I needed locks.

Here is a trivial example. In shell 1:

   $ flock lock -c 'sleep 10'

Immediately after in shell 2:

   $ time flock lock -c 'echo hello'
   hello

   real 0m9.704s
   user 0m0.000s
   sys  0m0.003s

Collin

[1] https://man7.org/linux/man-pages/man1/flock.1.html

Reply via email to