diff options
author | Karel Zak | 2017-06-26 13:42:25 +0200 |
---|---|---|
committer | Karel Zak | 2017-06-26 13:42:25 +0200 |
commit | c525260293279acf7ebf116d0b402e47f7a6a17c (patch) | |
tree | 0038041fc4c0838aa72aec7d812968d918dbef8d /disk-utils/mkfs.cramfs.c | |
parent | agetty: fix login name DEL/CTRL^U issue (diff) | |
parent | misc: no more errtryh() (diff) | |
download | kernel-qcow2-util-linux-c525260293279acf7ebf116d0b402e47f7a6a17c.tar.gz kernel-qcow2-util-linux-c525260293279acf7ebf116d0b402e47f7a6a17c.tar.xz kernel-qcow2-util-linux-c525260293279acf7ebf116d0b402e47f7a6a17c.zip |
Merge branch 'usage-part1' of https://github.com/rudimeier/util-linux
* 'usage-part1' of https://github.com/rudimeier/util-linux:
misc: no more errtryh()
mkfs.cramfs: add --help and --version
more: add --help and --version
whereis: add --help and --version
login: add --help and --version
fsck: add --help and --version
setarch: use errtryhelp()
dmesg: do not accept any non-option arguments
blkid: use errtryhelp instead of errtryh
misc: remove superfluous null pointer checks for optarg
uuidd: remove unused define
Diffstat (limited to 'disk-utils/mkfs.cramfs.c')
-rw-r--r-- | disk-utils/mkfs.cramfs.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c index 77b4467e7..87b378c81 100644 --- a/disk-utils/mkfs.cramfs.c +++ b/disk-utils/mkfs.cramfs.c @@ -122,15 +122,11 @@ struct entry { #define CRAMFS_GID_WIDTH 8 #define CRAMFS_OFFSET_WIDTH 26 -/* Input status of 0 to print help and exit without an error. */ -static void __attribute__((__noreturn__)) -usage(int status) { - FILE *stream = status ? stderr : stdout; - - fprintf(stream, +static void __attribute__((__noreturn__)) usage(void) +{ + printf( _("usage: %s [-h] [-v] [-b blksize] [-e edition] [-N endian] [-i file] " "[-n name] dirname outfile\n" - " -h print this help\n" " -v be verbose\n" " -E make all warnings errors " "(non-zero exit status)\n" @@ -147,7 +143,11 @@ usage(int status) { " outfile output file\n"), program_invocation_short_name, PAD_SIZE); - exit(status); + fputs(USAGE_SEPARATOR, stdout); + fputs(USAGE_HELP, stdout); + fputs(USAGE_VERSION, stdout); + printf(USAGE_MAN_TAIL("mkfs.cramfs(8)")); + exit(MKFS_EX_OK); } static char * @@ -717,11 +717,21 @@ int main(int argc, char **argv) textdomain(PACKAGE); atexit(close_stdout); + if (argc > 1) { + /* first arg may be one of our standard longopts */ + if (!strcmp(argv[1], "--help")) + usage(); + if (!strcmp(argv[1], "--version")) { + printf(UTIL_LINUX_VERSION); + exit(MKFS_EX_OK); + } + } + /* command line options */ while ((c = getopt(argc, argv, "hb:Ee:i:n:N:psVvz")) != EOF) { switch (c) { case 'h': - usage(MKFS_EX_OK); + usage(); case 'b': blksize = strtou32_or_err(optarg, _("invalid blocksize argument")); break; @@ -773,8 +783,10 @@ int main(int argc, char **argv) } } - if ((argc - optind) != 2) - usage(MKFS_EX_USAGE); + if ((argc - optind) != 2) { + warnx(_("bad usage")); + errtryhelp(MKFS_EX_USAGE); + } dirname = argv[optind]; outfile = argv[optind + 1]; |