aboutsummaryrefslogtreecommitdiffstats
path: root/awklib/eg/lib/inplace.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-05 11:20:41 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-05 11:20:41 +0300
commit4de12ef40f9ea9a0b715903cfe6da51b97eedb77 (patch)
tree84a0c8d117e9a2a629e186a1fe22ebe185e5d6a4 /awklib/eg/lib/inplace.awk
parent14da33f5ac17b4adfd15ddb12c07715741bd1b1f (diff)
parentdbf9d5a4fc4b6d6340912395f020019576ed37f6 (diff)
downloadegawk-4de12ef40f9ea9a0b715903cfe6da51b97eedb77.tar.gz
egawk-4de12ef40f9ea9a0b715903cfe6da51b97eedb77.tar.bz2
egawk-4de12ef40f9ea9a0b715903cfe6da51b97eedb77.zip
Merge branch 'master' into cmake
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)
}