3 ms·
My preferred way under those conditions would be more along the lines of "see if a safe command fails, do the desired command if not", like: if ls *.yaml > /
by Izkata 5y ago
My preferred way under those conditions would be more along the lines of "see if a safe command fails, do the desired command if not", like:
if ls *.yaml > /dev/null; then
the_tool *.yaml
fi
- xorcist 5y agoThat only looks simple because we don't know what problem was being solved. Is it really right to not process any files just because one of them just disappeared? In general, situations like this suffer from race conditions and time-of-check/time-of-use problems.
- Izkata 5y ago> Is it really right to not process any files just because one of them just disappeared? No idea what you mean here, the glob can expand to one or many. > In general, situations like this suffer from race conditions and time-of-check/time-of-use problems. I mean, that's a problem in every version presented so far, one that I don't think can be fixed externally without something extra like hardlinking to a new directory, because "the_tool" apparently can't handle missing files and they can go missing when "the_tool" starts up. That's why I didn't even bother.