From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114235 invoked by alias); 5 Jun 2019 08:36:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 114227 invoked by uid 89); 5 Jun 2019 08:36:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: mail-wr1-f68.google.com Received: from mail-wr1-f68.google.com (HELO mail-wr1-f68.google.com) (209.85.221.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Jun 2019 08:36:27 +0000 Received: by mail-wr1-f68.google.com with SMTP id w13so18490028wru.11 for ; Wed, 05 Jun 2019 01:36:27 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4eeb:42ff:feef:f164? ([2001:8a0:f913:f700:4eeb:42ff:feef:f164]) by smtp.gmail.com with ESMTPSA id q20sm29690561wra.36.2019.06.05.01.36.24 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 01:36:25 -0700 (PDT) Subject: Re: [PATCH] Style "pwd" output To: Tom Tromey , gdb-patches@sourceware.org References: <20190605020116.1550-1-tom@tromey.com> From: Pedro Alves Message-ID: <1ee4bd6b-4cdf-f3a9-74af-0843bf123a8b@redhat.com> Date: Wed, 05 Jun 2019 08:36:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190605020116.1550-1-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-06/txt/msg00114.txt.bz2 On 6/5/19 3:01 AM, Tom Tromey wrote: > This changes the "pwd" command to style its output. > Tested on x86-64 Fedora 29. > > gdb/ChangeLog > 2019-06-04 Tom Tromey > > * cli/cli-cmds.c (pwd_command): Style output. > > gdb/testsuite/ChangeLog > 2019-06-04 Tom Tromey > > * gdb.base/style.exp: Test "pwd". > --- > gdb/ChangeLog | 4 ++++ > gdb/cli/cli-cmds.c | 14 +++++++++----- > gdb/testsuite/ChangeLog | 4 ++++ > gdb/testsuite/gdb.base/style.exp | 2 ++ > 4 files changed, 19 insertions(+), 5 deletions(-) > > diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c > index 09f932c2d21..658b08e49a6 100644 > --- a/gdb/cli/cli-cmds.c > +++ b/gdb/cli/cli-cmds.c > @@ -49,6 +49,7 @@ > #include "cli/cli-script.h" > #include "cli/cli-setshow.h" > #include "cli/cli-cmds.h" > +#include "cli/cli-style.h" > #include "cli/cli-utils.h" > > #include "extension.h" > @@ -337,11 +338,14 @@ pwd_command (const char *args, int from_tty) > error (_("Error finding name of working directory: %s"), > safe_strerror (errno)); > > - if (strcmp (cwd.get (), current_directory) != 0) > - printf_unfiltered (_("Working directory %s\n (canonically %s).\n"), > - current_directory, cwd.get ()); > - else > - printf_unfiltered (_("Working directory %s.\n"), current_directory); > + fputs_filtered (_("Working directory "), gdb_stdout); > + fputs_styled (current_directory, file_name_style.style (), gdb_stdout); > + if (strcmp (cwd.get (), current_directory) == 0) > + { > + fputs_filtered (_("\n (canonically "), gdb_stdout); > + fputs_styled (cwd.get (), file_name_style.style (), gdb_stdout); > + } > + fputs_filtered (".\n", gdb_stdout); Seems fine to me. I wish we didn't have to split the lines across different calls though. I know we don't officially do i18n yet (*), but these kinds of changes will only make it more difficult to get there. Maybe with something like: if (strcmp (cwd.get (), current_directory) != 0) printf_unfiltered (_("Working directory %s