Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Style "pwd" output
@ 2019-06-05  2:01 Tom Tromey
  2019-06-05  8:36 ` Pedro Alves
  0 siblings, 1 reply; 37+ messages in thread
From: Tom Tromey @ 2019-06-05  2:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the "pwd" command to style its output.
Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-06-04  Tom Tromey  <tom@tromey.com>

	* cli/cli-cmds.c (pwd_command): Style output.

gdb/testsuite/ChangeLog
2019-06-04  Tom Tromey  <tom@tromey.com>

	* 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].*"
 }
-- 
2.17.2


^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2019-07-03 12:20 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-05  2:01 [PATCH] Style "pwd" output Tom Tromey
2019-06-05  8:36 ` Pedro Alves
2019-06-05 13:42   ` Tom Tromey
2019-06-05 15:21     ` Pedro Alves
2019-06-05 18:12       ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Pedro Alves
2019-06-05 20:27         ` Tom Tromey
2019-06-05 20:39           ` Pedro Alves
2019-06-05 20:42             ` Pedro Alves
2019-06-05 20:49               ` Tom Tromey
2019-06-05 20:47             ` Tom Tromey
2019-06-05 21:25               ` Pedro Alves
2019-06-05 22:21                 ` Tom Tromey
2019-06-06 15:49                   ` Pedro Alves
2019-06-06 23:55                     ` Tom Tromey
2019-06-07 18:27                   ` Tom Tromey
2019-06-07 19:20                     ` Tom Tromey
2019-07-01 12:23                       ` Pedro Alves
2019-07-01 12:55                         ` Pedro Alves
2019-07-01 13:06                           ` Pedro Alves
2019-07-01 17:26                             ` Tom Tromey
2019-07-01 19:24                               ` [users/palves/format_strings] Down with .ptr() (Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output)) Pedro Alves
2019-07-01 13:17                           ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Pedro Alves
2019-07-01 13:20                             ` Pedro Alves
2019-07-01 17:38                             ` Tom Tromey
2019-07-01 18:49                               ` Tom Tromey
2019-07-01 18:56                                 ` Pedro Alves
2019-07-01 19:30                                   ` [users/palves/format_strings] Document the gdb-specific formatters Pedro Alves
2019-07-01 19:25                               ` [users/palves/format_strings] Introduce string_field Pedro Alves
2019-07-01 17:43                         ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Tom Tromey
2019-07-01 19:29                           ` [users/palves/format_strings] Make printf_filtered support the gdb-specific formatters too Pedro Alves
2019-07-01 12:01                     ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Pedro Alves
2019-07-01 12:25                       ` Tom Tromey
2019-07-01 12:37                         ` Pedro Alves
2019-07-01 17:20                           ` Tom Tromey
2019-07-01 19:27                             ` [users/palves/format_strings] %pS/%pN -> %p[/%p] Pedro Alves
2019-07-01 19:32                         ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Philippe Waroquiers
2019-07-03 12:20                           ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox