From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965016AbbJVOlJ (ORCPT ); Thu, 22 Oct 2015 10:41:09 -0400 Received: from mail.kernel.org ([198.145.29.136]:34327 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964938AbbJVOlG (ORCPT ); Thu, 22 Oct 2015 10:41:06 -0400 Date: Thu, 22 Oct 2015 11:41:01 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Adrian Hunter , Borislav Petkov , Brendan Gregg , Chandler Carruth , Frederic Weisbecker , Stephane Eranian , Wang Nan Subject: Re: [PATCH 1/2] perf tools: Setup pager when printing usage and help Message-ID: <20151022144101.GE2455@kernel.org> References: <1445524112-5201-1-git-send-email-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1445524112-5201-1-git-send-email-namhyung@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Oct 22, 2015 at 11:28:31PM +0900, Namhyung Kim escreveu: > It's annoying to see error or help message when command has many options > like in perf record, report or top. So setup pager when print parser > error or help message - it should be OK since no UI is enabled at the > parsing time. The usage_with_options() already disables it by calling > exit_browser() anyway. But then we don't know what went wrong, try: [acme@zoo linux]$ perf record --all-cpus -g --42 --event cycles 2>&1 | head Error: unknown option `42' Usage: perf record [] [] or: perf record [] -- [] -e, --event event selector. use 'perf list' to list available events --filter event filter --exclude-perf don't record events from perf itself -p, --pid record events on existing process id [acme@zoo linux]$ Without this patch I can see what was the option that caused the problem (--42 in this case), after the patch I can see only the valid options, not the one causing the problem, well, I can see it only if I use the same 2>&1 technique above. - Arnaldo > Cc: Adrian Hunter > Cc: Borislav Petkov > Cc: Brendan Gregg > Cc: Chandler Carruth > Cc: Frederic Weisbecker > Cc: Stephane Eranian > Cc: Wang Nan > Signed-off-by: Namhyung Kim > --- > tools/perf/util/parse-options.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c > index 8aa7922397a9..388d385df5ad 100644 > --- a/tools/perf/util/parse-options.c > +++ b/tools/perf/util/parse-options.c > @@ -648,6 +648,8 @@ int usage_with_options_internal(const char * const *usagestr, > if (!usagestr) > return PARSE_OPT_HELP; > > + setup_pager(); > + > fprintf(stderr, "\n Usage: %s\n", *usagestr++); > while (*usagestr && **usagestr) > fprintf(stderr, " or: %s\n", *usagestr++); > -- > 2.6.0