From 1b744e421db2ff8dd3cf1a581a0b05920a358029 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Fri, 3 Aug 2018 02:00:05 +0200 Subject: [PATCH] Pipe 'help' through a pager. --- plugins/help | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/help b/plugins/help index 5626b5b..0222014 100755 --- a/plugins/help +++ b/plugins/help @@ -13,6 +13,19 @@ sub command :Tab(help,wtf,omgwtfbbq) { return NEXT if $command !~ /^(?:help|wtf|omgwtfbbq)$/; + # GNU less(1) and more(1) are a bad choice to present to total newbies who + # might have no interest in learning to use these surprisingly powerful + # tools, so I will not accepting patches to use either of those, or to use + # the PAGER environment variable (because that will typically be set to + # either one of those by default). For example, typing "v" will excute + # vi... + # On the other hand, busybox(1) has a "more" applet that gives the user + # clear instructions and seems mostly harmless too. + my $pipe; + if (open $pipe, "|-", "busybox", "more") { + select $pipe; + } + say "\n${bold}Valid commands:${off}"; my $width = max(map length s/[<>]//rg, keys %::HELP); @@ -38,5 +51,8 @@ ${bold}Advanced usage:${off} pass space separated arguments to parameters Complete each transaction with ${underline}account${off} (i.e. enter your name). END + select STDOUT; + close $pipe; + return ACCEPT; }