diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-02 11:26:39 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-02 11:26:39 +1200 |
commit | ca632bed9240bce35c6acffceeec7c46a3d9b3f1 (patch) | |
tree | 8c17a2f236f7146b78157239e75cd4fb2d3784a5 /bin/clwr | |
parent | Strip trailing newline from clrd() (diff) | |
download | dotfiles-ca632bed9240bce35c6acffceeec7c46a3d9b3f1.tar.gz dotfiles-ca632bed9240bce35c6acffceeec7c46a3d9b3f1.zip |
Move clrd()/clwr() to scripts
clrd(1) is POSIX sh, but clwr(1) ideally needs Readline, so I've left it
as #!/bin/bash for now.
Diffstat (limited to 'bin/clwr')
-rw-r--r-- | bin/clwr | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/clwr b/bin/clwr new file mode 100644 index 00000000..677e0a24 --- /dev/null +++ b/bin/clwr @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +self=clwr +if (($# != 1)) ; then + printf >&2 '%s: Need output file\n' "$self" + exit 2 +elif [[ ! -t 0 ]] ; then + printf >&2 '%s: stdin not a terminal\n' "$self" + exit 2 +elif [[ ! -t 1 ]] ; then + printf >&2 '%s: stdout not a terminal\n' "$self" + exit 2 +fi +exec 3>"$1" +while { clear && IFS= read -er line ; } ; do + printf '%s\n' >&3 +done |