summaryrefslogtreecommitdiffstats
path: root/cac
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-08-05 23:08:47 +0200
committertv <tv@shackspace.de>2015-08-05 23:09:53 +0200
commit71ef6469e17e876d99555e55532a61758e51a25b (patch)
treeef5d6df092f77b69f45cb7b6fa853230b985f543 /cac
parent2a19b0ade0967ae0e9919fde722f370007699f5c (diff)
cac help: invoke $PAGER when stdin is a terminal
Diffstat (limited to 'cac')
-rwxr-xr-xcac14
1 files changed, 12 insertions, 2 deletions
diff --git a/cac b/cac
index 08cc820..5762803 100755
--- a/cac
+++ b/cac
@@ -64,12 +64,22 @@ cac() {
}
#? cac help
-#? Print this help message.
+#? Show this help message.
#?
__cac_cli__help() {(
+ # test -t expects GNU coreutils
+ if test -t 0 >/dev/null 2>&1; then
+ filter() {
+ $PAGER "$@"
+ }
+ else
+ filter() {
+ cat "$@"
+ }
+ fi
exec sed < "$0" -n '
s/^#?\( \(.*\)\)\?/\2/p
- '
+ ' | filter
)}
#? cac console SERVERSPEC