From e0c1194c4348e7adf99802461d45e3dd1bd192ff Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 18 Mar 2015 21:43:14 +0200 Subject: Bug fix to inplace extension and doc updates. --- awklib/eg/lib/inplace.awk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'awklib/eg/lib') diff --git a/awklib/eg/lib/inplace.awk b/awklib/eg/lib/inplace.awk index 6403a228..d1574654 100644 --- a/awklib/eg/lib/inplace.awk +++ b/awklib/eg/lib/inplace.awk @@ -5,10 +5,15 @@ # Please set INPLACE_SUFFIX to make a backup copy. For example, you may # want to set INPLACE_SUFFIX to .bak on the command line or in a BEGIN rule. +# N.B. We call inplace_end() in the BEGINFILE and END rules so that any +# actions in an ENDFILE rule will be redirected as expected. + BEGINFILE { - inplace_begin(FILENAME, INPLACE_SUFFIX) + if (_inplace_filename != "") + inplace_end(_inplace_filename, INPLACE_SUFFIX) + inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX) } -ENDFILE { +END { inplace_end(FILENAME, INPLACE_SUFFIX) } -- cgit v1.2.3