mv -t: question about behavior when target is moved away

From:

Voelker, Bernhard

Subject:

mv -t: question about behavior when target is moved away

Date:

Thu, 8 Dec 2011 13:54:22 +0100

Just about a corner case:
when the target directory is renamed during a `mv -t` run,
then the behaviour is different than if it wasn't there at
program start.
Consider the following example:
n=20000
mkdir target
seq $n | xargs touch
seq $n | xargs mv --target-directory=target &
sleep 1
mv -v target target.renamed
What happens is that after the target has been renamed,
mv starts complaining about every file which couldn't be
moved:
`target' -> `target.renamed'
mv: cannot move `7484' to `target/7484': No such file or directory
mv: cannot move `7485' to `target/7485': No such file or directory
...
while after some time, when xargs has executed a new mv process,
that one refuses to start with:
mv: accessing `target': No such file or directory
I feel somehow strange about the former error message.
Well, if the target appears again during such a run, then
moving continues normally. So maybe trying to continue is
right, but in conjunction with xargs, it is strange that
mv sometimes tries to continue and sometimes not.
As --target-directory is by design for use with xargs,
I would have expected a more consistent behavior:
maybe break out of the loop with the same message
as in the latter case.
Is this behavior on purpose / a feature / required by some
standard?
Have a nice day,
Berny

reply via email to

[Prev in Thread]

Current Thread

[Next in Thread]

mv -t: question about behavior when target is moved away,
Voelker, Bernhard<=