The for loop asks the filesystem for a list of files matching the given pattern. By definition, all files exist! The filesystem does not invent files that are not there. So there is no need to test if the files exist [ -e "$file" ].
If there is another process that is deleting the same files at the same moment, then there is possibility that a file ceases to exist between the moment the list was created and the moment we are testing it. But that is also true between the moment of the test and the moment mv is called. So, if there are no deleting process running in parallel, then there is no need to test if the file exist.
Thank you for your help @frederic-mahe that's a good point.
I do not remember the process that led to this construction.
Maybe it was a way to avoid problems.
I will delete this non-sense condition
In
script.sh
, there are a couple of instances ofloop + test
where thetest
is (almost) always true:https://github.com/ImagoXV/NanoASV/blob/831a9455b1d171a92ad4a97130f969318801e72b/script.sh#L446-L447
The
for loop
asks the filesystem for a list of files matching the given pattern. By definition, all files exist! The filesystem does not invent files that are not there. So there is no need to test if the files exist[ -e "$file" ]
.If there is another process that is deleting the same files at the same moment, then there is possibility that a file ceases to exist between the moment the list was created and the moment we are testing it. But that is also true between the moment of the test and the moment
mv
is called. So, if there are no deleting process running in parallel, then there is no need to test if the file exist.