Comment 18 for bug 833101

Revision history for this message
Dave Martin (dave-martin-arm) wrote : Re: [Bug 833101] Re: perf uses less at the default pager, but the linux-tools packages have no dependency for it

On Thu, May 10, 2012 at 12:30:52PM -0000, Avik Sil wrote:
> Does this patch look OK?
>
> diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c
> index 1915de2..d6f23de 100644
> --- a/tools/perf/util/pager.c
> +++ b/tools/perf/util/pager.c
> @@ -57,8 +57,12 @@ void setup_pager(void)
> }
> if (!pager)
> pager = getenv("PAGER");
> - if (!pager)
> - pager = "less";
> + if (!pager) {
> + if (!access("/usr/bin/pager", X_OK))
> + pager = "/usr/bin/pager";
> + else
> + pager = "less";

To conform to the existing code style, you might want to write the code
as follows:

+ if (!pager) {
+ if (!access("/usr/bin/pager", X_OK))
+ pager = "/usr/bin/pager";
+ }
+ if (!pager)
+ pager = "less";

Functionally, the code looks OK to me either way.

Cheers
---Dave