[PATCH v4 2/8] tools, pager: Support overwriting the pager
From: Andi Kleen
Date: Thu Sep 13 2018 - 23:11:21 EST
- Next message: Andi Kleen: "[PATCH v4 3/8] tools, perf, script: Add --insn-trace for instruction decoding"
- Previous message: Andi Kleen: "[PATCH v4 4/8] perf, tools, script: Allow sym and dso without ip, addr"
- In reply to: Andi Kleen: "[PATCH v4 4/8] perf, tools, script: Allow sym and dso without ip, addr"
- Next in thread: Andi Kleen: "[PATCH v4 3/8] tools, perf, script: Add --insn-trace for instruction decoding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Add an interface to the auto pager code that allows callers
to overwrite the pager.
Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
---
tools/lib/subcmd/pager.c | 11 ++++++++++-
tools/lib/subcmd/pager.h | 1 +
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/lib/subcmd/pager.c b/tools/lib/subcmd/pager.c
index 9997a8805a82..e3d47b59b14d 100644
--- a/tools/lib/subcmd/pager.c
+++ b/tools/lib/subcmd/pager.c
@@ -23,6 +23,13 @@ void pager_init(const char *pager_env)
subcmd_config.pager_env = pager_env;
}
+static const char *forced_pager;
+
+void force_pager(const char *pager)
+{
+ forced_pager = pager;
+}
+
static void pager_preexec(void)
{
/*
@@ -66,7 +73,9 @@ void setup_pager(void)
const char *pager = getenv(subcmd_config.pager_env);
struct winsize sz;
- if (!isatty(1))
+ if (forced_pager)
+ pager = forced_pager;
+ if (!isatty(1) && !forced_pager)
return;
if (ioctl(1, TIOCGWINSZ, &sz) == 0)
pager_columns = sz.ws_col;
diff --git a/tools/lib/subcmd/pager.h b/tools/lib/subcmd/pager.h
index f1a53cf29880..a818964693ab 100644
--- a/tools/lib/subcmd/pager.h
+++ b/tools/lib/subcmd/pager.h
@@ -7,5 +7,6 @@ extern void pager_init(const char *pager_env);
extern void setup_pager(void);
extern int pager_in_use(void);
extern int pager_get_columns(void);
+extern void force_pager(const char *);
#endif /* __SUBCMD_PAGER_H */
--
2.17.1
- Next message: Andi Kleen: "[PATCH v4 3/8] tools, perf, script: Add --insn-trace for instruction decoding"
- Previous message: Andi Kleen: "[PATCH v4 4/8] perf, tools, script: Allow sym and dso without ip, addr"
- In reply to: Andi Kleen: "[PATCH v4 4/8] perf, tools, script: Allow sym and dso without ip, addr"
- Next in thread: Andi Kleen: "[PATCH v4 3/8] tools, perf, script: Add --insn-trace for instruction decoding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]