Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools lib subcmd: Support overwriting the pager

Add an interface to the auto pager code that allows callers to overwrite
the pager.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kim Phillips <kim.phillips@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20180918123214.26728-3-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Andi Kleen and committed by
Arnaldo Carvalho de Melo
03a1f49f c12e039d

+11 -1
+10 -1
tools/lib/subcmd/pager.c
··· 23 23 subcmd_config.pager_env = pager_env; 24 24 } 25 25 26 + static const char *forced_pager; 27 + 28 + void force_pager(const char *pager) 29 + { 30 + forced_pager = pager; 31 + } 32 + 26 33 static void pager_preexec(void) 27 34 { 28 35 /* ··· 73 66 const char *pager = getenv(subcmd_config.pager_env); 74 67 struct winsize sz; 75 68 76 - if (!isatty(1)) 69 + if (forced_pager) 70 + pager = forced_pager; 71 + if (!isatty(1) && !forced_pager) 77 72 return; 78 73 if (ioctl(1, TIOCGWINSZ, &sz) == 0) 79 74 pager_columns = sz.ws_col;
+1
tools/lib/subcmd/pager.h
··· 7 7 extern void setup_pager(void); 8 8 extern int pager_in_use(void); 9 9 extern int pager_get_columns(void); 10 + extern void force_pager(const char *); 10 11 11 12 #endif /* __SUBCMD_PAGER_H */