From patchwork Wed Jun 5 02:01:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33012 Received: (qmail 665 invoked by alias); 5 Jun 2019 02:01:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 128804 invoked by uid 89); 5 Jun 2019 02:01:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.130) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Jun 2019 02:01:21 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway33.websitewelcome.com (Postfix) with ESMTP id ED187E77B for ; Tue, 4 Jun 2019 21:01:18 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id YLEshpNlh90onYLEshrClZ; Tue, 04 Jun 2019 21:01:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NeyHfXgiCj1UT+hfaDc0IKReexFufDArcscBSbEsG3U=; b=QRBwjyr0pp8X3O4Xerwuk4+5ud oJwRfc7EMlT/jNRqxW+cCGdAyt/Gcm6Lu5XQkM9PcjfY0ktOjPSj9jIoTx1YYq9EMAwMd1Vo3ZJB3 hacQUd3g0yGpRXdgC93BdgSWi; Received: from 174-29-48-168.hlrn.qwest.net ([174.29.48.168]:52486 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hYLEs-000iI9-P1; Tue, 04 Jun 2019 21:01:18 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Style "pwd" output Date: Tue, 4 Jun 2019 20:01:16 -0600 Message-Id: <20190605020116.1550-1-tom@tromey.com> 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); } void diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index a17f2014865..0b2d52a9dea 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -127,4 +127,6 @@ save_vars { env(TERM) } { gdb_test "file $binfile" \ "Reading symbols from [style $quoted file]..." \ "filename is styled when loading symbol file" + + gdb_test "pwd" "Working directory [style .*? file].*" }