The behavior of dash (and also bash) looks non-intuitive in this case.
It seems that new_file
is created before ls
is executed.
Is it specified in POSIX?
The behavior of dash (and also bash) looks non-intuitive in this case.
It seems that new_file
is created before ls
is executed.
Is it specified in POSIX?
ls
is not executed beforecat >newfile
: the two are executed at the same time. Whethernew_file
is created before or afterls
reaches the point where it would list it is a race. It's a race that>new_file
will usually win, because creating a file takes less long than reading an executable and starting to execute it. But if you run it a large number of times, I expect you'll sometimes seels
win. – Gilles 'SO- stop being evil' Jun 11 '20 at 19:28