diff --git a/cat/cat.c b/cat/cat.c index 0370fbde0..4d671ca91 100644 --- a/cat/cat.c +++ b/cat/cat.c @@ -224,8 +224,11 @@ main (int argc, char *argv[]) CHECK_OPTION_format_consumed; /* User must have specified some drives. */ - if (drvs == NULL) + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + guestfs_int_program_name); usage (EXIT_FAILURE); + } /* Add drives, inspect and mount. */ add_drives (drvs, 'a'); diff --git a/cat/filesystems.c b/cat/filesystems.c index 3f9d931fd..f1c28525a 100644 --- a/cat/filesystems.c +++ b/cat/filesystems.c @@ -291,8 +291,13 @@ main (int argc, char *argv[]) assert (live == 0); /* Must be no extra arguments on the command line. */ - if (optind != argc) + if (optind != argc) { + fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n" + "Make sure to specify the argument for --format " + "like '--format=%s'.\n"), + guestfs_int_program_name, argv[optind], argv[optind]); usage (EXIT_FAILURE); + } CHECK_OPTION_format_consumed; @@ -329,8 +334,11 @@ main (int argc, char *argv[]) title = 0; /* User must have specified some drives. */ - if (drvs == NULL) + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + guestfs_int_program_name); usage (EXIT_FAILURE); + } /* Add drives. */ add_drives (drvs, 'a'); diff --git a/cat/log.c b/cat/log.c index daefda732..6632f5aec 100644 --- a/cat/log.c +++ b/cat/log.c @@ -184,14 +184,22 @@ main (int argc, char *argv[]) assert (live == 0); /* User must not specify more arguments on the command line. */ - if (optind != argc) + if (optind != argc) { + fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n" + "Make sure to specify the argument for --format " + "like '--format=%s'.\n"), + guestfs_int_program_name, argv[optind], argv[optind]); usage (EXIT_FAILURE); + } CHECK_OPTION_format_consumed; /* User must have specified some drives. */ - if (drvs == NULL) + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + guestfs_int_program_name); usage (EXIT_FAILURE); + } /* Add drives, inspect and mount. Note that inspector is always true, * and there is no -m option. diff --git a/cat/ls.c b/cat/ls.c index 91f2125ac..f9907375f 100644 --- a/cat/ls.c +++ b/cat/ls.c @@ -340,8 +340,11 @@ main (int argc, char *argv[]) usage (EXIT_FAILURE); /* User must have specified some drives. */ - if (drvs == NULL) + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + guestfs_int_program_name); usage (EXIT_FAILURE); + } /* Add drives, inspect and mount. */ add_drives (drvs, 'a'); diff --git a/diff/diff.c b/diff/diff.c index d7542fc6f..210abc22b 100644 --- a/diff/diff.c +++ b/diff/diff.c @@ -311,10 +311,14 @@ main (int argc, char *argv[]) } } - if (drvs == NULL || drvs2 == NULL) { - fprintf (stderr, - _("%s: you must specify some -a|-A|-d|-D options, see %s(1)\n"), - guestfs_int_program_name, guestfs_int_program_name); + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + guestfs_int_program_name); + usage (EXIT_FAILURE); + } + if (drvs2 == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -A or -D option.\n"), + guestfs_int_program_name); usage (EXIT_FAILURE); } @@ -324,8 +328,13 @@ main (int argc, char *argv[]) if (human && csv) error (EXIT_FAILURE, 0, _("you cannot use -h and --csv options together.")); - if (optind != argc) - error (EXIT_FAILURE, 0, _("extra arguments on the command line")); + if (optind != argc) { + fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n" + "Make sure to specify the argument for --checksum or --format " + "like '--format=%s'.\n"), + guestfs_int_program_name, argv[optind], argv[optind]); + usage (EXIT_FAILURE); + } /* These are really constants, but they have to be variables for the * options parsing code. Assert here that they have known-good diff --git a/edit/edit.c b/edit/edit.c index 6e7aee48a..2d3ccc61f 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -253,8 +253,11 @@ main (int argc, char *argv[]) CHECK_OPTION_format_consumed; /* User must have specified some drives. */ - if (drvs == NULL) + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + guestfs_int_program_name); usage (EXIT_FAILURE); + } /* Add drives. */ add_drives (drvs, 'a'); diff --git a/format/format.c b/format/format.c index 4aa31deeb..5026aff76 100644 --- a/format/format.c +++ b/format/format.c @@ -219,14 +219,22 @@ main (int argc, char *argv[]) assert (live == 0); /* Must be no extra arguments on the command line. */ - if (optind != argc) + if (optind != argc) { + fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n" + "Make sure to specify the argument for --format, --lvm " + "or --partition like '--format=%s'.\n"), + guestfs_int_program_name, argv[optind], argv[optind]); usage (EXIT_FAILURE); + } CHECK_OPTION_format_consumed; /* The user didn't specify any drives to format. */ - if (drvs == NULL) + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a option.\n"), + guestfs_int_program_name); usage (EXIT_FAILURE); + } /* Because the libguestfs kernel can get stuck rereading the * partition table after things have been erased, we sometimes need diff --git a/fuse/guestmount.c b/fuse/guestmount.c index fc03a9cc5..f72ecb82f 100644 --- a/fuse/guestmount.c +++ b/fuse/guestmount.c @@ -311,9 +311,16 @@ main (int argc, char *argv[]) /* Check we have the right options. */ if (!live) { - if (!drvs || !(mps || inspector)) - error (EXIT_FAILURE, 0, - _("must have at least one -a/-d and at least one -m/-i option")); + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + guestfs_int_program_name); + usage (EXIT_FAILURE); + } + if (!(mps || inspector)) { + fprintf (stderr, _("%s: error: you must specify either -i at least one -m option.\n"), + guestfs_int_program_name); + usage (EXIT_FAILURE); + } } else { size_t count_d = 0, count_other = 0; struct drv *drv; diff --git a/inspector/inspector.c b/inspector/inspector.c index 6d4694da4..d8e455ebf 100644 --- a/inspector/inspector.c +++ b/inspector/inspector.c @@ -233,8 +233,13 @@ main (int argc, char *argv[]) assert (live == 0); /* Must be no extra arguments on the command line. */ - if (optind != argc) + if (optind != argc) { + fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n" + "Make sure to specify the argument for --format " + "like '--format=%s'.\n"), + guestfs_int_program_name, argv[optind], argv[optind]); usage (EXIT_FAILURE); + } CHECK_OPTION_format_consumed; @@ -252,8 +257,11 @@ main (int argc, char *argv[]) } /* User must have specified some drives. */ - if (drvs == NULL) + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + guestfs_int_program_name); usage (EXIT_FAILURE); + } /* Add drives, inspect and mount. Note that inspector is always true, * and there is no -m option. diff --git a/rescue/rescue.c b/rescue/rescue.c index c46c7757e..135c9e678 100644 --- a/rescue/rescue.c +++ b/rescue/rescue.c @@ -275,14 +275,22 @@ main (int argc, char *argv[]) assert (live == 0); /* Must be no extra arguments on the command line. */ - if (optind != argc) + if (optind != argc) { + fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n" + "Make sure to specify the argument for --format or --scratch " + "like '--format=%s'.\n"), + guestfs_int_program_name, argv[optind], argv[optind]); usage (EXIT_FAILURE); + } CHECK_OPTION_format_consumed; /* User must have specified some drives. */ - if (drvs == NULL) + if (drvs == NULL) { + fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"), + guestfs_int_program_name); usage (EXIT_FAILURE); + } /* Setting "direct mode" is required for the rescue appliance. */ if (guestfs_set_direct (g, 1) == -1)