X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=cat%2Fvirt-cat.c;h=ebae8952216af9ff7fc9a08ef262b1d804f42762;hb=6f09e4774ce64a15424a2601df10326d764cc7f7;hp=58ebd8ec6c61b3c42ebe7efbdc0ca440962373a4;hpb=d29e9a552f5823d1d8cb8d4962cb1301bbf60b0e;p=libguestfs.git diff --git a/cat/virt-cat.c b/cat/virt-cat.c index 58ebd8e..ebae895 100644 --- a/cat/virt-cat.c +++ b/cat/virt-cat.c @@ -69,7 +69,7 @@ usage (int status) " --keys-from-stdin Read passphrases from stdin\n" " -v|--verbose Verbose messages\n" " -V|--version Display version and exit\n" - " -x Echo each command before executing it\n" + " -x Trace libguestfs API calls\n" "For more information, see the manpage %s(1).\n"), program_name, program_name, program_name, program_name); @@ -220,6 +220,10 @@ main (int argc, char *argv[]) if (optind >= argc || argc - optind < 1) usage (EXIT_FAILURE); + /* User must have specified some drives. */ + if (drvs == NULL) + usage (EXIT_FAILURE); + /* Add drives, inspect and mount. Note that inspector is always true, * and there is no -m option. */ @@ -233,13 +237,15 @@ main (int argc, char *argv[]) /* Free up data structures, no longer needed after this point. */ free_drives (drvs); + unsigned errors = 0; + while (optind < argc) { if (guestfs_download (g, argv[optind], "/dev/stdout") == -1) - exit (EXIT_FAILURE); + errors++; optind++; } guestfs_close (g); - exit (EXIT_SUCCESS); + exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); }