fish: Make '-x' option enable traces instead of using separate echo path.
authorRichard Jones <rjones@redhat.com>
Sat, 8 May 2010 08:04:28 +0000 (09:04 +0100)
committerRichard Jones <rjones@redhat.com>
Fri, 14 May 2010 16:22:53 +0000 (17:22 +0100)
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
fish/reopen.c

index 61a8405..3f798fd 100644 (file)
@@ -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];
index f2d35c7..2dfc8db 100644 (file)
@@ -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);