aboutsummaryrefslogtreecommitdiffstats
path: root/test/ofs1.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-08-05 12:58:33 +0300
committerArnold D. Robbins <arnold@skeeve.com>2012-08-05 12:58:33 +0300
commit9bf467bbe0bf6868919b2a672f70b945f320c7a8 (patch)
treefae9239d2abb81635790f2db9da33fdb9a89ec1c /test/ofs1.awk
parent7bfc288d27bacb715ff63dbf71be53304917685a (diff)
downloadegawk-9bf467bbe0bf6868919b2a672f70b945f320c7a8.tar.gz
egawk-9bf467bbe0bf6868919b2a672f70b945f320c7a8.tar.bz2
egawk-9bf467bbe0bf6868919b2a672f70b945f320c7a8.zip
New test for OFS from Nelson Beebe.
Diffstat (limited to 'test/ofs1.awk')
-rwxr-xr-xtest/ofs1.awk23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ofs1.awk b/test/ofs1.awk
new file mode 100755
index 00000000..83b3c2a5
--- /dev/null
+++ b/test/ofs1.awk
@@ -0,0 +1,23 @@
+# Translate this shell script into gawk:
+#
+#! /bin/sh -
+#
+# awktest()
+# {
+# echo a:b:c | $AWK -F":" '{$2="x"; OFS=FS; print}'
+# echo a:b:c | $AWK -F":" '{$2="x"; print; OFS=FS; print}'
+# echo a:b:c | $AWK -F":" '{$2="x"; print $1; OFS=FS; print}'
+# echo a:b:c | $AWK -F":" '{$2="x"; print; $2=$2; OFS=FS; print}'
+# }
+#
+# AWK=./gawk
+# awktest > foo.gawk
+
+BEGIN { FS = ":" }
+
+# Have to reset OFS at end since not running separate invocations
+
+FNR == 1 { $2 = "x"; OFS = FS; print ; OFS = " "}
+FNR == 2 { $2 = "x"; print; OFS = FS; print ; OFS = " "}
+FNR == 3 { $2 = "x"; print $1; OFS = FS; print ; OFS = " "}
+FNR == 4 { $2 = "x"; print; $2 = $2; OFS = FS; print }