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?
lsis not executed beforecat >newfile: the two are executed at the same time. Whethernew_fileis created before or afterlsreaches the point where it would list it is a race. It's a race that>new_filewill 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 seelswin. – Gilles 'SO- stop being evil' Jun 11 '20 at 19:28