Sometimes I need to remove all the contents of a directory and create new files there. Can I do something like this and expect all new files to remain intact:
% rm -rf regression/* & ( sleep 10 ; run_regression )
run_regression timestamps its output files so that they would have unique names and places them in
My thinking is that the shell would resolve
regression/* into an explicit list of pre-existing filenames and then
rm would be removing the files on that explicit list, but not the new files that
run_regression would be creating contemporaneously with
run_regression timestamps its files there should be no name clashes.
However, I'm not quite sure how to tell when the shell is done listing the files and
rm starts to work. Is the above 10 sec adequate? Can I do something like this in
% rm -rf regression/* & ( wait_unil_names_are_resolved ; run_regression )
Per comment clarifying that I am indeed asking whether the shell guarantees that wildcards would be expanded into filenames before invoking the tool, even if it's a tool intimately known to the shell. I can imagine that the developer of both the shell and the tool may be tempted to pipeline wildcard expansion with the tool; I hope though that there are standards preventing that.