aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-02-04 20:53:32 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-02-04 20:53:32 +1300
commit797e8673ed6a3eec7db0294e30f84759629e49c8 (patch)
tree0354bad4fa96a0afa5d1faee07932bc93aa894a5
parentRemove double-shebang header (diff)
downloaddotfiles-797e8673ed6a3eec7db0294e30f84759629e49c8.tar.gz
dotfiles-797e8673ed6a3eec7db0294e30f84759629e49c8.zip
Add wro(1df)
-rw-r--r--README.markdown4
-rwxr-xr-xbin/wro31
-rw-r--r--man/man1/quo.1df2
-rw-r--r--man/man1/wro.1df20
4 files changed, 56 insertions, 1 deletions
diff --git a/README.markdown b/README.markdown
index a76a0641..7c469f0a 100644
--- a/README.markdown
+++ b/README.markdown
@@ -410,6 +410,9 @@ Installed by the `install-bin` target:
* `htenc(1df)` encodes.
* `htdec(1df)` decodes.
* `htrec(1df)` wraps `a` tags around URLs.
+* Two internet message quoting tools:
+ * `quo(1df)` indents with quoting right angle-brackets.
+ * `wro(1df)` adds a quote attribution header to its input.
* `ap(1df)` reads arguments for a given command from the standard input,
prompting if appropriate.
* `apf(1df)` prepends arguments to a command with ones read from a file,
@@ -486,7 +489,6 @@ Installed by the `install-bin` target:
[`plenv`](https://github.com/tokuhirom/plenv), filters out any modules in
`~/.plenv/non-cpan-modules`, and updates them all.
* `pwg(1df)` generates just one decent password with `pwgen(1)`.
-* `quo(1df)` quotes its input with right angle brackets.
* `rgl(1df)` is a very crude interactive `grep(1)` loop.
* `shb(1df)` attempts to build shebang lines for scripts from the system
paths.
diff --git a/bin/wro b/bin/wro
new file mode 100755
index 00000000..82bb4415
--- /dev/null
+++ b/bin/wro
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Add an email-style quote header to input
+self=wro
+
+# Check arguments
+if [ "$#" -gt 2 ] ; then
+ printf >&2 '%s: Too many arguments\n' "$self"
+ exit 2
+fi
+
+# Check first argument for the person to quote; if blank, try to form a
+# reasonable-looking name from the system
+if [ -n "$1" ] ; then
+ from=$1
+else
+ un=$(id -n)
+ if [ -f /etc/mailname ] ; then
+ read -r hn < /etc/mailname
+ else
+ hn=$(uname -n)
+ fi
+ from="$un"@"$hn"
+fi
+
+# Check second argument for the date; if blank, get the system date in whatever
+# format it cares to give us
+date=${2:-"$(date)"}
+
+# Print the header and then the input
+printf 'On %s, %s wrote:\n' "$date" "$from"
+cat
diff --git a/man/man1/quo.1df b/man/man1/quo.1df
index d2fd268d..0b651388 100644
--- a/man/man1/quo.1df
+++ b/man/man1/quo.1df
@@ -19,5 +19,7 @@ FILE1 [FILE2...]
quotes its input by insert a right-angle bracket followed by a space at the
start of every unquoted line. If the line was already quoted, it adds another
level of right-angle bracket.
+.SH SEE ALSO
+wro(1df)
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/wro.1df b/man/man1/wro.1df
new file mode 100644
index 00000000..350ca448
--- /dev/null
+++ b/man/man1/wro.1df
@@ -0,0 +1,20 @@
+.TH WRO 1df "January 2017" "Manual page for wro"
+.SH NAME
+.B wro
+\- add a quote header to the standard input
+.SH SYNOPSIS
+.B wro
+luser@example.com
+.br
+.B wro
+luser@example.com '2017-01-15 9:00am'
+Text on standard input.
+^D
+.SH DESCRIPTION
+.B wro
+adds an email-style quote lead-in to its standard input. It's intended to
+receive input from quo(1df).
+.SH SEE ALSO
+quo(1df)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>