From 9ef4d50bc49bd8443937cc972711320488239a24 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sat, 8 May 2010 09:04:28 +0100 Subject: [PATCH 1/1] fish: Make '-x' option enable traces instead of using separate echo path. Previously we had separate code paths for echoing commands (-x) and tracing (guestfs_set_trace). This just unifies that so that the guestfish -x option enables tracing. (cherry picked from commit 8e007581c91a5193e6aec0f6f9aeb379a935c9d4 and commit a96d70113ffcd01f55262c3d0fbe711bee759fec and commit 87eecb507ee09a62f3a12f5f75d3417a09c0c8d4 which are all logically part of the same fix) --- fish/fish.c | 12 +++--------- fish/reopen.c | 4 ++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/fish/fish.c b/fish/fish.c index 61a8405..3f798fd 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -69,7 +69,6 @@ guestfs_h *g; int read_only = 0; int quit = 0; int verbose = 0; -int echo_commands = 0; int remote_control_listen = 0; int remote_control = 0; int exit_on_error = 1; @@ -324,7 +323,7 @@ main (int argc, char *argv[]) exit (EXIT_SUCCESS); case 'x': - echo_commands = 1; + guestfs_set_trace (g, 1); break; case HELP_OPTION: @@ -380,6 +379,8 @@ main (int argc, char *argv[]) strcat (cmd, " -v"); if (!guestfs_get_autosync (g)) strcat (cmd, " -n"); + if (guestfs_get_trace (g)) + strcat (cmd, " -x"); if (verbose) fprintf (stderr, @@ -805,13 +806,6 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd) /* This counts the commands issued, starting at 1. */ command_num++; - if (echo_commands) { - printf ("%s", cmd); - for (i = 0; argv[i] != NULL; ++i) - printf (" %s", argv[i]); - printf ("\n"); - } - /* For | ... commands. Annoyingly we can't use popen(3) here. */ if (pipecmd) { int fd[2]; diff --git a/fish/reopen.c b/fish/reopen.c index f2d35c7..2dfc8db 100644 --- a/fish/reopen.c +++ b/fish/reopen.c @@ -54,6 +54,10 @@ do_reopen (const char *cmd, int argc, char *argv[]) if (r >= 0) guestfs_set_verbose (g2, r); + r = guestfs_get_trace (g); + if (r >= 0) + guestfs_set_trace (g2, r); + r = guestfs_get_autosync (g); if (r >= 0) guestfs_set_autosync (g2, r); -- 1.8.3.1