On 3/15/2015 5:38 PM, Andrew J. Schorr
wrote:
Hi Ed,
On Sun, Mar 15, 2015 at 12:35:09PM -0500, Ed Morton wrote:
On 3/15/2015 11:26 AM, Andrew J. Schorr wrote:
The "inplace" include file contains an ENDFILE rule that terminates the
inplace processing. Consider an alternative approach: bash-4.2$ awk
'ENDFILE {print "bar"}; @include "inplace"' file bash-4.2$ cat file bar
bash-4.2$ This includes the "inplace" ENDFILE rule after yours, so that
the print occurs before the "inplace" processing is terminated. In other
words, the ordering of the ENDFILE rules matters.
Could you move the code that terminates the inplace processing from the
ENDFILE to a BEGINFILE rule?
You're certainly free to replace inplace.awk with your own version.
For example, you could try:
@load "inplace"
BEGINFILE {
if (INPLACE_FILENAME)
inplace_end(INPLACE_FILENAME, INPLACE_SUFFIX)
inplace_begin(FILENAME, INPLACE_SUFFIX)
INPLACE_FILENAME = FILENAME
}
END {
inplace_end(FILENAME, INPLACE_SUFFIX)
}
I haven't tested this, but maybe it would behave more sensibly. If you give it
a try, please report back on your results.
Regards,
Andy