aboutsummaryrefslogtreecommitdiff
path: root/bin/clog.sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-01-15 12:31:26 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-01-15 12:31:26 +1300
commit99c655cd11cd9000a496bde9c9fced98308c6454 (patch)
treedfec0895cc9448af3c8eb6ffb7eac0b662315456 /bin/clog.sh
parentMerge branch 'hotfix/v0.22.1' (diff)
parentBump version number to 0.23.0 (diff)
downloaddotfiles-99c655cd11cd9000a496bde9c9fced98308c6454.tar.gz
dotfiles-99c655cd11cd9000a496bde9c9fced98308c6454.zip
Merge branch 'release/v0.23.0'v0.23.0
* release/v0.23.0: Bump version number to 0.23.0 Remove unused `self` var from clog(1df) Change double-quote printf pattern to single-quote Move ShellCheck line to correct place in sra(1df) Quote EDITOR/VISUAL assignments for clarity Explicitly ignore uninteresting tree(1) opts Refactor clog(1df), allow args and non-term stdin Reimplement bl(1df) in Awk Separate ax(1df) manpage args from command Make newline explicit for ax(1df) Make first ax(1df) arg safer, warn on second arg Correct monospaced blocks in Vim plugin docs
Diffstat (limited to 'bin/clog.sh')
-rw-r--r--bin/clog.sh24
1 files changed, 12 insertions, 12 deletions
diff --git a/bin/clog.sh b/bin/clog.sh
index 1b612d68..3269c508 100644
--- a/bin/clog.sh
+++ b/bin/clog.sh
@@ -1,17 +1,17 @@
# Record a timestamped message to a logfile, defaulting to ~/.clog
-self=clog
-# Ignore arguments
-set --
+# Build the cat(1) command we'll run, wrapping it in rlwrap(1) if available and
+# applicable.
+if [ "$#" -eq 0 ] && [ -t 0 ] && command -v rlwrap >/dev/null 2>&1 ; then
+ set -- rlwrap --history-filename=/dev/null cat -- "${@:--}"
+else
+ set -- cat -- "${@:--}"
+fi
-# If we have rlwrap, quietly use it
-command -v rlwrap >/dev/null 2>&1 &&
- set -- rlwrap --history-filename=/dev/null -C "$self" "$@"
-
-# Write the date, the standard input (rlwrapped if applicable), and two dashes
-# to $CLOG, defaulting to ~/.clog.
+# Write the date, the input, and two dashes to $CLOG, defaulting to ~/.clog.
+clog=${CLOG:-"$HOME"/.clog}
{
date
- "$@" cat -
- printf '%s\n' --
-} >>"${CLOG:-"$HOME"/.clog}"
+ "$@"
+ printf -- '--\n'
+} >> "$clog"