aboutsummaryrefslogtreecommitdiff
path: root/bin
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 /bin
parentRemove double-shebang header (diff)
downloaddotfiles-797e8673ed6a3eec7db0294e30f84759629e49c8.tar.gz
dotfiles-797e8673ed6a3eec7db0294e30f84759629e49c8.zip
Add wro(1df)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/wro31
1 files changed, 31 insertions, 0 deletions
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