aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--awklib/eg/lib/inplace.awk18
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/gawk.info198
-rw-r--r--doc/gawk.texi23
-rw-r--r--doc/gawktexi.in23
-rw-r--r--extension/ChangeLog5
-rw-r--r--extension/inplace.3am9
-rw-r--r--test/ChangeLog5
-rw-r--r--test/inplace1.ok2
-rw-r--r--test/inplace2.ok2
-rw-r--r--test/inplace3.ok4
11 files changed, 194 insertions, 100 deletions
diff --git a/awklib/eg/lib/inplace.awk b/awklib/eg/lib/inplace.awk
index d1574654..15a83f58 100644
--- a/awklib/eg/lib/inplace.awk
+++ b/awklib/eg/lib/inplace.awk
@@ -5,15 +5,29 @@
# 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.
+# By default, each filename on the command line will be edited inplace.
+# But you can selectively disable this by adding an inplace=0 argument
+# prior to files that you do not want to process this way. You can then
+# reenable it later on the commandline by putting inplace=1 before files
+# that you wish to be subject to inplace editing.
+
# 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.
+BEGIN {
+ inplace = 1 # enabled by default
+}
+
BEGINFILE {
if (_inplace_filename != "")
inplace_end(_inplace_filename, INPLACE_SUFFIX)
- inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ if (inplace)
+ inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ else
+ _inplace_filename = ""
}
END {
- inplace_end(FILENAME, INPLACE_SUFFIX)
+ if (_inplace_filename != "")
+ inplace_end(_inplace_filename, INPLACE_SUFFIX)
}
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 1a0a265f..41766ad0 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-17 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * gawktexi.in: Document new inplace variable to control whether
+ inplace editing is active.
+
2015-06-13 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in: Comment out exercise 10.3, since the answer
diff --git a/doc/gawk.info b/doc/gawk.info
index bd325521..d3dc7d3d 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -25838,17 +25838,31 @@ The 'inplace' extension emulates GNU 'sed''s '-i' option, which performs
# 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.
+ # By default, each filename on the command line will be edited inplace.
+ # But you can selectively disable this by adding an inplace=0 argument
+ # prior to files that you do not want to process this way. You can then
+ # reenable it later on the commandline by putting inplace=1 before files
+ # that you wish to be subject to inplace editing.
+
# 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.
+ BEGIN {
+ inplace = 1 # enabled by default
+ }
+
BEGINFILE {
if (_inplace_filename != "")
inplace_end(_inplace_filename, INPLACE_SUFFIX)
- inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ if (inplace)
+ inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ else
+ _inplace_filename = ""
}
END {
- inplace_end(FILENAME, INPLACE_SUFFIX)
+ if (_inplace_filename != "")
+ inplace_end(_inplace_filename, INPLACE_SUFFIX)
}
For each regular file that is processed, the extension redirects
@@ -25859,6 +25873,12 @@ extension restores standard output to its original destination. If
a backup file name created by appending that suffix. Finally, the
temporary file is renamed to the original file name.
+ Note that the use of this feature can be controlled by placing
+'inplace=0' on the command-line prior to listing files that should not
+be processed this way. You can reenable inplace editing by adding an
+'inplace=1' argument prior to files that should be subject to inplace
+editing.
+
The '_inplace_filename' variable serves to keep track of the current
filename so as to not invoke 'inplace_end()' before processing the first
file.
@@ -35329,92 +35349,92 @@ Node: Extension Sample File Functions1035812
Node: Extension Sample Fnmatch1043461
Node: Extension Sample Fork1044948
Node: Extension Sample Inplace1046166
-Node: Extension Sample Ord1048252
-Node: Extension Sample Readdir1049088
-Ref: table-readdir-file-types1049977
-Node: Extension Sample Revout1050782
-Node: Extension Sample Rev2way1051371
-Node: Extension Sample Read write array1052111
-Node: Extension Sample Readfile1054053
-Node: Extension Sample Time1055148
-Node: Extension Sample API Tests1056496
-Node: gawkextlib1056988
-Node: Extension summary1059435
-Node: Extension Exercises1063127
-Node: Language History1064624
-Node: V7/SVR3.11066280
-Node: SVR41068433
-Node: POSIX1069867
-Node: BTL1071247
-Node: POSIX/GNU1071977
-Node: Feature History1077816
-Node: Common Extensions1092135
-Node: Ranges and Locales1093418
-Ref: Ranges and Locales-Footnote-11098034
-Ref: Ranges and Locales-Footnote-21098061
-Ref: Ranges and Locales-Footnote-31098296
-Node: Contributors1098517
-Node: History summary1104086
-Node: Installation1105466
-Node: Gawk Distribution1106411
-Node: Getting1106895
-Node: Extracting1107718
-Node: Distribution contents1109356
-Node: Unix Installation1115452
-Node: Quick Installation1116134
-Node: Shell Startup Files1118548
-Node: Additional Configuration Options1119626
-Node: Configuration Philosophy1121431
-Node: Non-Unix Installation1123801
-Node: PC Installation1124259
-Node: PC Binary Installation1125579
-Node: PC Compiling1127431
-Ref: PC Compiling-Footnote-11130455
-Node: PC Testing1130564
-Node: PC Using1131744
-Node: Cygwin1135858
-Node: MSYS1136628
-Node: VMS Installation1137129
-Node: VMS Compilation1137920
-Ref: VMS Compilation-Footnote-11139150
-Node: VMS Dynamic Extensions1139208
-Node: VMS Installation Details1140893
-Node: VMS Running1143146
-Node: VMS GNV1145987
-Node: VMS Old Gawk1146722
-Node: Bugs1147193
-Node: Other Versions1151307
-Node: Installation summary1157781
-Node: Notes1158839
-Node: Compatibility Mode1159704
-Node: Additions1160486
-Node: Accessing The Source1161411
-Node: Adding Code1162847
-Node: New Ports1169002
-Node: Derived Files1173490
-Ref: Derived Files-Footnote-11178975
-Ref: Derived Files-Footnote-21179010
-Ref: Derived Files-Footnote-31179608
-Node: Future Extensions1179722
-Node: Implementation Limitations1180380
-Node: Extension Design1181563
-Node: Old Extension Problems1182717
-Ref: Old Extension Problems-Footnote-11184235
-Node: Extension New Mechanism Goals1184292
-Ref: Extension New Mechanism Goals-Footnote-11187656
-Node: Extension Other Design Decisions1187845
-Node: Extension Future Growth1189958
-Node: Old Extension Mechanism1190794
-Node: Notes summary1192557
-Node: Basic Concepts1193739
-Node: Basic High Level1194420
-Ref: figure-general-flow1194702
-Ref: figure-process-flow1195387
-Ref: Basic High Level-Footnote-11198688
-Node: Basic Data Typing1198873
-Node: Glossary1202201
-Node: Copying1234147
-Node: GNU Free Documentation License1271686
-Node: Index1296804
+Node: Extension Sample Ord1049095
+Node: Extension Sample Readdir1049931
+Ref: table-readdir-file-types1050820
+Node: Extension Sample Revout1051625
+Node: Extension Sample Rev2way1052214
+Node: Extension Sample Read write array1052954
+Node: Extension Sample Readfile1054896
+Node: Extension Sample Time1055991
+Node: Extension Sample API Tests1057339
+Node: gawkextlib1057831
+Node: Extension summary1060278
+Node: Extension Exercises1063970
+Node: Language History1065467
+Node: V7/SVR3.11067123
+Node: SVR41069276
+Node: POSIX1070710
+Node: BTL1072090
+Node: POSIX/GNU1072820
+Node: Feature History1078659
+Node: Common Extensions1092978
+Node: Ranges and Locales1094261
+Ref: Ranges and Locales-Footnote-11098877
+Ref: Ranges and Locales-Footnote-21098904
+Ref: Ranges and Locales-Footnote-31099139
+Node: Contributors1099360
+Node: History summary1104929
+Node: Installation1106309
+Node: Gawk Distribution1107254
+Node: Getting1107738
+Node: Extracting1108561
+Node: Distribution contents1110199
+Node: Unix Installation1116295
+Node: Quick Installation1116977
+Node: Shell Startup Files1119391
+Node: Additional Configuration Options1120469
+Node: Configuration Philosophy1122274
+Node: Non-Unix Installation1124644
+Node: PC Installation1125102
+Node: PC Binary Installation1126422
+Node: PC Compiling1128274
+Ref: PC Compiling-Footnote-11131298
+Node: PC Testing1131407
+Node: PC Using1132587
+Node: Cygwin1136701
+Node: MSYS1137471
+Node: VMS Installation1137972
+Node: VMS Compilation1138763
+Ref: VMS Compilation-Footnote-11139993
+Node: VMS Dynamic Extensions1140051
+Node: VMS Installation Details1141736
+Node: VMS Running1143989
+Node: VMS GNV1146830
+Node: VMS Old Gawk1147565
+Node: Bugs1148036
+Node: Other Versions1152150
+Node: Installation summary1158624
+Node: Notes1159682
+Node: Compatibility Mode1160547
+Node: Additions1161329
+Node: Accessing The Source1162254
+Node: Adding Code1163690
+Node: New Ports1169845
+Node: Derived Files1174333
+Ref: Derived Files-Footnote-11179818
+Ref: Derived Files-Footnote-21179853
+Ref: Derived Files-Footnote-31180451
+Node: Future Extensions1180565
+Node: Implementation Limitations1181223
+Node: Extension Design1182406
+Node: Old Extension Problems1183560
+Ref: Old Extension Problems-Footnote-11185078
+Node: Extension New Mechanism Goals1185135
+Ref: Extension New Mechanism Goals-Footnote-11188499
+Node: Extension Other Design Decisions1188688
+Node: Extension Future Growth1190801
+Node: Old Extension Mechanism1191637
+Node: Notes summary1193400
+Node: Basic Concepts1194582
+Node: Basic High Level1195263
+Ref: figure-general-flow1195545
+Ref: figure-process-flow1196230
+Ref: Basic High Level-Footnote-11199531
+Node: Basic Data Typing1199716
+Node: Glossary1203044
+Node: Copying1234990
+Node: GNU Free Documentation License1272529
+Node: Index1297647

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index d61a47de..c781d372 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -34975,17 +34975,31 @@ properly:
# 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.
+# By default, each filename on the command line will be edited inplace.
+# But you can selectively disable this by adding an inplace=0 argument
+# prior to files that you do not want to process this way. You can then
+# reenable it later on the commandline by putting inplace=1 before files
+# that you wish to be subject to inplace editing.
+
# 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.
+BEGIN @{
+ inplace = 1 # enabled by default
+@}
+
BEGINFILE @{
if (_inplace_filename != "")
inplace_end(_inplace_filename, INPLACE_SUFFIX)
- inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ if (inplace)
+ inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ else
+ _inplace_filename = ""
@}
END @{
- inplace_end(FILENAME, INPLACE_SUFFIX)
+ if (_inplace_filename != "")
+ inplace_end(_inplace_filename, INPLACE_SUFFIX)
@}
@end group
@c endfile
@@ -34999,6 +35013,11 @@ If @code{INPLACE_SUFFIX} is not an empty string, the original file is
linked to a backup @value{FN} created by appending that suffix. Finally,
the temporary file is renamed to the original @value{FN}.
+Note that the use of this feature can be controlled by placing @samp{inplace=0}
+on the command-line prior to listing files that should not be processed this
+way. You can reenable inplace editing by adding an @samp{inplace=1} argument
+prior to files that should be subject to inplace editing.
+
The @code{_inplace_filename} variable serves to keep track of the
current filename so as to not invoke @code{inplace_end()} before
processing the first file.
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 47482816..7ca02a05 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -34066,17 +34066,31 @@ properly:
# 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.
+# By default, each filename on the command line will be edited inplace.
+# But you can selectively disable this by adding an inplace=0 argument
+# prior to files that you do not want to process this way. You can then
+# reenable it later on the commandline by putting inplace=1 before files
+# that you wish to be subject to inplace editing.
+
# 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.
+BEGIN @{
+ inplace = 1 # enabled by default
+@}
+
BEGINFILE @{
if (_inplace_filename != "")
inplace_end(_inplace_filename, INPLACE_SUFFIX)
- inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ if (inplace)
+ inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ else
+ _inplace_filename = ""
@}
END @{
- inplace_end(FILENAME, INPLACE_SUFFIX)
+ if (_inplace_filename != "")
+ inplace_end(_inplace_filename, INPLACE_SUFFIX)
@}
@end group
@c endfile
@@ -34090,6 +34104,11 @@ If @code{INPLACE_SUFFIX} is not an empty string, the original file is
linked to a backup @value{FN} created by appending that suffix. Finally,
the temporary file is renamed to the original @value{FN}.
+Note that the use of this feature can be controlled by placing @samp{inplace=0}
+on the command-line prior to listing files that should not be processed this
+way. You can reenable inplace editing by adding an @samp{inplace=1} argument
+prior to files that should be subject to inplace editing.
+
The @code{_inplace_filename} variable serves to keep track of the
current filename so as to not invoke @code{inplace_end()} before
processing the first file.
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 3188c1e1..9ff809da 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-17 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * inplace.3am: Document new inplace variable to control whether
+ inplace editing is active.
+
2015-05-19 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.3: Release tar ball made.
diff --git a/extension/inplace.3am b/extension/inplace.3am
index 64aec91c..b1682e22 100644
--- a/extension/inplace.3am
+++ b/extension/inplace.3am
@@ -1,4 +1,4 @@
-.TH INPLACE 3am "Apr 08 2015" "Free Software Foundation" "GNU Awk Extension Modules"
+.TH INPLACE 3am "Jun 17 2015" "Free Software Foundation" "GNU Awk Extension Modules"
.SH NAME
inplace \- emulate sed/perl/ruby in-place editing
.SH SYNOPSIS
@@ -32,6 +32,13 @@ rule or on the command line, then the
extension concatenates that suffix onto the original
filename and uses the result as a filename for renaming
the original.
+.PP
+One can disable inplace editing selectively by placing
+.B inplace=0
+on the command line prior to files that should be processed normally.
+One can reenable inplace editing by placing
+.B inplace=1
+prior to files that should be subject to inplace editing.
... .SH NOTES
... .SH BUGS
.SH EXAMPLE
diff --git a/test/ChangeLog b/test/ChangeLog
index b80398e8..c2f8811e 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-17 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * inplace1.ok, inplace2.ok, inplace3.ok: Update line number in error
+ messages, since inplace.awk changed a bit.
+
2015-05-29 Arnold D. Robbins <arnold@skeeve.com>
* checknegtime.awk: New file.
diff --git a/test/inplace1.ok b/test/inplace1.ok
index 82562235..91b5276b 100644
--- a/test/inplace1.ok
+++ b/test/inplace1.ok
@@ -1,5 +1,5 @@
before
-gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+gawk: inplace:25: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
stdin start
is bar replaced?
stdin end
diff --git a/test/inplace2.ok b/test/inplace2.ok
index 82562235..91b5276b 100644
--- a/test/inplace2.ok
+++ b/test/inplace2.ok
@@ -1,5 +1,5 @@
before
-gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+gawk: inplace:25: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
stdin start
is bar replaced?
stdin end
diff --git a/test/inplace3.ok b/test/inplace3.ok
index a7b7254f..deb926b9 100644
--- a/test/inplace3.ok
+++ b/test/inplace3.ok
@@ -1,11 +1,11 @@
before
-gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+gawk: inplace:25: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
stdin start
is bar replaced?
stdin end
after
Before
-gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+gawk: inplace:25: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
stdin start
is foo replaced?
stdin end