aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-05 19:05:46 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-05 19:08:37 +1300
commitfd0203ff3ad2de81bd828eda809a89f8be7458d6 (patch)
treebcc705a44e3ba2aa1a3b2951c2d0dadc2c09aacb /bin
parentAdd onl(1df) (diff)
downloaddotfiles-fd0203ff3ad2de81bd828eda809a89f8be7458d6.tar.gz
dotfiles-fd0203ff3ad2de81bd828eda809a89f8be7458d6.zip
Adopt much simpler approach for onl(1df)
Diffstat (limited to 'bin')
-rw-r--r--bin/onl.awk27
1 files changed, 7 insertions, 20 deletions
diff --git a/bin/onl.awk b/bin/onl.awk
index 140fb64c..c12039db 100644
--- a/bin/onl.awk
+++ b/bin/onl.awk
@@ -1,27 +1,14 @@
# Flatten input into one single-space separated line with no unprintable chars
-# For each not-all-spaces line:
+# For each line of input ...
{
- # Strip unprintable chars
- gsub(/[^[:print:]]/, "")
+ # Strip out non-printable characters and rebuild the fields
+ gsub(/[^[:print:]]+/, "")
- # All horizontal whitespace groups to one space
- gsub(/[ \t]+/, " ")
-
- # No leading or trailing space
- sub(/^ /, "")
- sub(/ $/, "")
-
- # If there's nothing left, go on to the next line
- if (!length)
- next
-
- # If this isn't the first line, add a leading space
- if (NR > 1)
- printf " "
-
- # Print the content without a newline
- printf "%s", $0
+ # Print each field, without a newline; add a leading space if it's not the
+ # very first one
+ for (i = 1; i <= NF; i++)
+ printf (f++) ? " %s" : "%s", $i
}
# Print a newline to close the line