aboutsummaryrefslogtreecommitdiffstats
path: root/awklib/eg
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-03-18 21:54:45 +0200
committerArnold D. Robbins <arnold@skeeve.com>2015-03-18 21:54:45 +0200
commit480aca31c7772dafeb1b97cd7a768bca2f49d3c7 (patch)
tree0c8b33ff856793d1cc21f976a822a1d8b29991fe /awklib/eg
parentcd2ff61aaf4938092517880ad7655828d99a3cb9 (diff)
parent925f9363c4b0a5bb9375298afcdcf404efb32587 (diff)
downloadegawk-480aca31c7772dafeb1b97cd7a768bca2f49d3c7.tar.gz
egawk-480aca31c7772dafeb1b97cd7a768bca2f49d3c7.tar.bz2
egawk-480aca31c7772dafeb1b97cd7a768bca2f49d3c7.zip
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'awklib/eg')
-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)
}