ImagoXV / NanoASV

NanoASV official repo
GNU General Public License v3.0
3 stars 0 forks source link

bash script: condition is always true #78

Open frederic-mahe opened 2 hours ago

frederic-mahe commented 2 hours ago

In script.sh, there are a couple of instances of loop + test where the test 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.

ImagoXV commented 2 hours ago

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