LIBGUESTFS_PATH implementation.
[libguestfs.git] / fish / fish.c
index d256c2b..0fc14ce 100644 (file)
@@ -78,13 +78,14 @@ usage (void)
           "  ...\n"
           "  EOF\n"
           "Options:\n"
-          "  -h|--cmd-help       List available commands\n"
-          "  -h|--cmd-help cmd   Display detailed help on 'cmd'\n"
-          "  -a image            Add image\n"
-          "  -m dev[:mnt]        Mount dev on mnt (if omitted, /)\n"
-          /*"  --ro|-r             All mounts are read-only\n"*/
-          "  -v|--verbose        Verbose messages\n"
-          "For more information, see the manpage guestfish(1).\n");
+          "  -h|--cmd-help        List available commands\n"
+          "  -h|--cmd-help cmd    Display detailed help on 'cmd'\n"
+          "  -a|--add image       Add image\n"
+          "  -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n"
+          "  -n|--no-sync         Don't autosync\n"
+        /*"  --ro|-r              All mounts are read-only\n"*/
+          "  -v|--verbose         Verbose messages\n"
+          "For more information,  see the manpage guestfish(1).\n");
 }
 
 int
@@ -96,6 +97,7 @@ main (int argc, char *argv[])
     { "cmd-help", 2, 0, 'h' },
     { "help", 0, 0, '?' },
     { "mount", 1, 0, 'm' },
+    { "no-sync", 0, 0, 'n' },
     { "verbose", 0, 0, 'v' },
     { 0, 0, 0, 0 }
   };
@@ -113,6 +115,16 @@ main (int argc, char *argv[])
     exit (1);
   }
 
+  guestfs_set_autosync (g, 1);
+
+  /* If developing, add . to the path.  Note that libtools interferes
+   * with this because uninstalled guestfish is a shell script that runs
+   * the real program with an absolute path.  Detect that too.
+   */
+  if (argv[0] &&
+      (argv[0][0] != '/' || strstr (argv[0], "/.libs/lt-") != NULL))
+    guestfs_set_path (g, ".:" GUESTFS_DEFAULT_PATH);
+
   for (;;) {
     c = getopt_long (argc, argv, options, long_options, NULL);
     if (c == -1) break;
@@ -153,6 +165,10 @@ main (int argc, char *argv[])
       mps = mp->next;
       break;
 
+    case 'n':
+      guestfs_set_autosync (g, 0);
+      break;
+
     case 'v':
       verbose++;
       guestfs_set_verbose (g, verbose);
@@ -239,7 +255,8 @@ script (int prompt)
   int len, i;
 
   if (prompt)
-    printf ("Welcome to guestfish, the libguestfs filesystem interactive shell for\n"
+    printf ("\n"
+           "Welcome to guestfish, the libguestfs filesystem interactive shell for\n"
            "editing virtual machine filesystems.\n"
            "\n"
            "Type: 'help' for help with commands\n"
@@ -334,7 +351,7 @@ issue_command (const char *cmd, char *argv[])
   }
   else if (strcasecmp (cmd, "cdrom") == 0) {
     if (argc != 1) {
-      fprintf (stderr, "use 'cdrom image' to add a guest cdrom\n");
+      fprintf (stderr, "use 'cdrom image' to add a CD-ROM image\n");
       return -1;
     }
     else
@@ -360,9 +377,9 @@ list_builtin_commands (void)
   printf ("%-20s %s\n",
          "quit", "quit guestfish");
   printf ("%-20s %s\n",
-         "add", "add  a guest image to be examined or modified");
+         "add", "add a guest image to be examined or modified");
   printf ("%-20s %s\n",
-         "cdrom", "add  a guest CD-ROM image to be examined");
+         "cdrom", "add a CD-ROM image to be examined");
   printf ("%-20s %s\n",
          "launch", "launch the subprocess");
 }
@@ -374,7 +391,7 @@ display_builtin_command (const char *cmd)
     printf ("add - add a guest image to be examined or modified\n"
            "     add <image>\n");
   else if (strcasecmp (cmd, "cdrom") == 0)
-    printf ("cdrom - add a guest CD-ROM image to be examined\n"
+    printf ("cdrom - add a CD-ROM image to be examined\n"
            "     cdrom <iso-file>\n");
   else if (strcasecmp (cmd, "help") == 0)
     printf ("help - display a list of commands or help on a command\n"