From c8362f016b245baa4b0ff4305e16d7428d66ef79 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Aug 20 2012 21:42:41 +0000 Subject: Fix behavior when userformat is invoked without an argument --- diff --git a/ChangeLog b/ChangeLog index 4edc66b..7716553 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-08-20 Miloslav Trmač + * usermount.c (main): Reject running (userformat) without arguments + instead of treating it like (usermount). + * usermount.1: Clarify that the "device" argument to (userformat) is + required. + * userinfo.c (parse_args): Don't output an additional error message when getopt() has already provided a more precise one. diff --git a/usermount.1 b/usermount.1 index cb1bc6b..f3a1e39 100644 --- a/usermount.1 +++ b/usermount.1 @@ -25,11 +25,9 @@ usermount \- A graphical tool to mount, unmount and format filesystems. .B userformat [ -.I device -] -[ .I options ] +.I device .SH DESCRIPTION .B usermount is a graphical tool to allow users to easily manage removable media, diff --git a/usermount.c b/usermount.c index bc1e6e1..3aafadd 100644 --- a/usermount.c +++ b/usermount.c @@ -657,25 +657,30 @@ format_one_device (const char *device) int main(int argc, char *argv[]) { + char *name; + bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); gtk_init(&argc, &argv); - if (argc > 1) { - char *name = strrchr (argv[0], '/'); - - name = name ? name + 1: argv[0]; - if (argc == 2 && !strcmp (name, "userformat")) { - format_one_device (argv[1]); - } else { + name = strrchr (argv[0], '/'); + name = name ? name + 1: argv[0]; + if (strcmp(name, "userformat") == 0) { + if (argc != 2) { fprintf(stderr, _("Unexpected command-line arguments\n")); return 1; } + format_one_device(argv[1]); } else { gboolean run_main; + if (argc != 1) { + fprintf(stderr, + _("Unexpected command-line arguments\n")); + return 1; + } run_main = create_usermount_window(); if (run_main) { gtk_main();