diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-05 20:06:39 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-05 20:46:47 +1200 |
commit | c8ab406749124d2e762ad5cf53963070113afd0f (patch) | |
tree | 54c9721a06957ebe7098a211eea803b0230c0f5d /bin/wro.sh | |
parent | Handle POSIX correctness in ~/.bash_profile (diff) | |
download | dotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.tar.gz dotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.zip |
Apply runtime shebanging to POSIX shell
Diffstat (limited to 'bin/wro.sh')
-rw-r--r-- | bin/wro.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/wro.sh b/bin/wro.sh new file mode 100644 index 00000000..3888c526 --- /dev/null +++ b/bin/wro.sh @@ -0,0 +1,30 @@ +# 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 -nu) + 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 |