2021-04-16 14:07:01 +0100, Martijn Dekker via austin-group-l at The Open Group: > Op 15-04-21 om 22:43 schreef Harald van Dijk: > [...] > > In specific cases, the shell may be able to detect that these issues > > cannot be a problem. In those specific cases, the optimisation should be > > perfectly valid and any reasons why it should or should not be performed > > are not of a technical nature. > > It makes sense now: instead of stdio, ksh93 uses libast's sfio, which on > most systems is capable of peeking ahead on arbitrary files without > consuming data. And it doesn't care if the input is a file or a string > because both are turned into sfio input streams. Thanks to Chet and Harald > for confirming that I've not overlooked some reason why the optimisation > shouldn't be re-enabled. [...]
Also consider a script such as: #! /bin/sh - trap 'echo "that was round $n"' EXIT n=0; oncemore() { n="$(( n + 1 ))"; } echo oncemore >> "$0" Which keeps track of how many times it has been executed. Or someone adding more lines to a script while it is being run, expecting those to be interpreted. (both quite far fetched scenarios though). -- Stephane