aboutsummaryrefslogtreecommitdiffstats
path: root/awklib/eg/lib/inplace.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-03-18 21:43:14 +0200
committerArnold D. Robbins <arnold@skeeve.com>2015-03-18 21:43:14 +0200
commite0c1194c4348e7adf99802461d45e3dd1bd192ff (patch)
tree6c8f968291e3a1c594758b19cbfcaace934523d7 /awklib/eg/lib/inplace.awk
parentcffd09247c1681fbf3d5cad5253b3199704f83e7 (diff)
downloadegawk-e0c1194c4348e7adf99802461d45e3dd1bd192ff.tar.gz
egawk-e0c1194c4348e7adf99802461d45e3dd1bd192ff.tar.bz2
egawk-e0c1194c4348e7adf99802461d45e3dd1bd192ff.zip
Bug fix to inplace extension and doc updates.
Diffstat (limited to 'awklib/eg/lib/inplace.awk')
-rw-r--r--awklib/eg/lib/inplace.awk9
1 files changed, 7 insertions, 2 deletions
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)
}