From: Masatake YAMATO Date: Tue, 24 Oct 2023 17:21:45 +0000 (+0900) Subject: Make the ways of using output stream consistent in usage() X-Git-Tag: v2.40-rc1~177^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bad4c729483ab31bb1cadc541817c139f41fb8aa;p=thirdparty%2Futil-linux.git Make the ways of using output stream consistent in usage() Signed-off-by: Masatake YAMATO --- diff --git a/Documentation/boilerplate.c b/Documentation/boilerplate.c index 535e85c387..2d6045979c 100644 --- a/Documentation/boilerplate.c +++ b/Documentation/boilerplate.c @@ -37,26 +37,26 @@ static void __attribute__((__noreturn__)) usage(void) { fputs(USAGE_HEADER, stdout); - printf(_(" %s [options] file...\n"), program_invocation_short_name); + fprintf(stdout, _(" %s [options] file...\n"), program_invocation_short_name); fputs(USAGE_SEPARATOR, stdout); - puts(_("Short program description.")); + fputs(_("Short program description."), stdout); fputs(USAGE_OPTIONS, stdout); - puts(_(" -n, --no-argument option does not use argument")); - puts(_(" --optional[=] option argument is optional")); - puts(_(" -r, --required option requires an argument")); - puts(_(" -z no long option")); - puts(_(" --xyzzy a long option only")); - puts(_(" -e, --extremely-long-long-option\n" - " use next line for description when needed")); - puts(_(" -l, --long-explanation an example of very verbose, and chatty option\n" - " description on two, or multiple lines, where the\n" - " consecutive lines are intended by two spaces")); - puts(_(" -f, --foobar next option description resets indent")); + fputs(_(" -n, --no-argument option does not use argument"), stdout); + fputs(_(" --optional[=] option argument is optional"), stdout); + fputs(_(" -r, --required option requires an argument"), stdout); + fputs(_(" -z no long option"), stdout); + fputs(_(" --xyzzy a long option only"), stdout); + fputs(_(" -e, --extremely-long-long-option\n" + " use next line for description when needed"), stdout); + fputs(_(" -l, --long-explanation an example of very verbose, and chatty option\n" + " description on two, or multiple lines, where the\n" + " consecutive lines are intended by two spaces"), stdout); + fputs(_(" -f, --foobar next option description resets indent"), stdout); fputs(USAGE_SEPARATOR, stdout); - printf(USAGE_HELP_OPTIONS(25)); /* char offset to align option descriptions */ - printf(USAGE_MAN_TAIL("fixme-command-name(1)")); + fprintf(stdout, USAGE_HELP_OPTIONS(25)); /* char offset to align option descriptions */ + fprintf(stdout, USAGE_MAN_TAIL("fixme-command-name(1)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/addpart.c b/disk-utils/addpart.c index 33abb36cab..2cf664b98f 100644 --- a/disk-utils/addpart.c +++ b/disk-utils/addpart.c @@ -19,8 +19,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_("Tell the kernel about the existence of a specified partition.\n"), out); fputs(USAGE_OPTIONS, out); - printf(USAGE_HELP_OPTIONS(16)); - printf(USAGE_MAN_TAIL("addpart(8)")); + fprintf(out, USAGE_HELP_OPTIONS(16)); + fprintf(out, USAGE_MAN_TAIL("addpart(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c index e02707d1d8..22497d23ad 100644 --- a/disk-utils/blockdev.c +++ b/disk-utils/blockdev.c @@ -201,36 +201,36 @@ static void __attribute__((__noreturn__)) usage(void) size_t i; fputs(USAGE_HEADER, stdout); - printf(_( + fprintf(stdout, _( " %1$s [-v|-q] commands devices\n" " %1$s --report [devices]\n" " %1$s -h|-V\n" ), program_invocation_short_name); fputs(USAGE_SEPARATOR, stdout); - puts( _("Call block device ioctls from the command line.")); + fputs( _("Call block device ioctls from the command line."), stdout); fputs(USAGE_OPTIONS, stdout); - puts( _(" -q quiet mode")); - puts( _(" -v verbose mode")); - puts( _(" --report print report for specified (or all) devices")); + fputs( _(" -q quiet mode"), stdout); + fputs( _(" -v verbose mode"), stdout); + fputs( _(" --report print report for specified (or all) devices"), stdout); fputs(USAGE_SEPARATOR, stdout); - printf(USAGE_HELP_OPTIONS(16)); + fprintf(stdout, USAGE_HELP_OPTIONS(16)); fputs(USAGE_SEPARATOR, stdout); - puts( _("Available commands:")); - printf(_(" %-25s get size in 512-byte sectors\n"), "--getsz"); + fputs(_("Available commands:"), stdout); + fprintf(stdout, _(" %-25s get size in 512-byte sectors\n"), "--getsz"); for (i = 0; i < ARRAY_SIZE(bdcms); i++) { if (bdcms[i].argname) - printf(" %s %-*s %s\n", bdcms[i].name, + fprintf(stdout, " %s %-*s %s\n", bdcms[i].name, (int)(24 - strlen(bdcms[i].name)), bdcms[i].argname, _(bdcms[i].help)); else - printf(" %-25s %s\n", bdcms[i].name, + fprintf(stdout, " %-25s %s\n", bdcms[i].name, _(bdcms[i].help)); } - printf(USAGE_MAN_TAIL("blockdev(8)")); + fprintf(stdout, USAGE_MAN_TAIL("blockdev(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c index e5c1fd8283..01069b7af2 100644 --- a/disk-utils/cfdisk.c +++ b/disk-utils/cfdisk.c @@ -2737,9 +2737,9 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -r, --read-only forced open cfdisk in read-only mode\n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(26)); + fprintf(out, USAGE_HELP_OPTIONS(26)); - printf(USAGE_MAN_TAIL("cfdisk(8)")); + fprintf(out, USAGE_MAN_TAIL("cfdisk(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/delpart.c b/disk-utils/delpart.c index 7ee0c525f0..cd6bf5c55d 100644 --- a/disk-utils/delpart.c +++ b/disk-utils/delpart.c @@ -19,8 +19,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_("Tell the kernel to forget about a specified partition.\n"), out); fputs(USAGE_OPTIONS, out); - printf(USAGE_HELP_OPTIONS(16)); - printf(USAGE_MAN_TAIL("delpart(8)")); + fprintf(out, USAGE_HELP_OPTIONS(16)); + fprintf(out, USAGE_MAN_TAIL("delpart(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/fdformat.c b/disk-utils/fdformat.c index 23609adf98..e776a278d7 100644 --- a/disk-utils/fdformat.c +++ b/disk-utils/fdformat.c @@ -157,8 +157,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -n, --no-verify disable the verification after the format\n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(19)); - printf(USAGE_MAN_TAIL("fdformat(8)")); + fprintf(out, USAGE_HELP_OPTIONS(19)); + fprintf(out, USAGE_MAN_TAIL("fdformat(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 79b904f253..c5c5f0fc71 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -884,11 +884,11 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -S, --sectors specify the number of sectors per track\n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(31)); + fprintf(out, USAGE_HELP_OPTIONS(31)); list_available_columns(out); - printf(USAGE_MAN_TAIL("fdisk(8)")); + fprintf(out, USAGE_MAN_TAIL("fdisk(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c index 1b11e82614..49f1b995d7 100644 --- a/disk-utils/fsck.c +++ b/disk-utils/fsck.c @@ -1412,11 +1412,11 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -V explain what is being done\n"), out); fputs(USAGE_SEPARATOR, out); - printf( " -?, --help %s\n", USAGE_OPTSTR_HELP); - printf( " --version %s\n", USAGE_OPTSTR_VERSION); + fprintf(out, " -?, --help %s\n", USAGE_OPTSTR_HELP); + fprintf(out, " --version %s\n", USAGE_OPTSTR_VERSION); fputs(USAGE_SEPARATOR, out); fputs(_("See the specific fsck.* commands for available fs-options."), out); - printf(USAGE_MAN_TAIL("fsck(8)")); + fprintf(out, USAGE_MAN_TAIL("fsck(8)")); exit(FSCK_EX_OK); } diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c index 10711200a2..789a9b5cfa 100644 --- a/disk-utils/fsck.cramfs.c +++ b/disk-utils/fsck.cramfs.c @@ -126,9 +126,9 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -b, --blocksize use this blocksize, defaults to page size\n"), out); fputs(_(" --extract[=] test uncompression, optionally extract into \n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(26)); + fprintf(out, USAGE_HELP_OPTIONS(26)); - printf(USAGE_MAN_TAIL("fsck.cramfs(8)")); + fprintf(out, USAGE_MAN_TAIL("fsck.cramfs(8)")); exit(FSCK_EX_OK); } diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index bd44f5bd12..11b10562cc 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -192,8 +192,8 @@ usage(void) { fputs(_(" -m, --uncleared activate mode not cleared warnings\n"), out); fputs(_(" -f, --force force check\n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(18)); - printf(USAGE_MAN_TAIL("fsck.minix(8)")); + fprintf(out, USAGE_HELP_OPTIONS(18)); + fprintf(out, USAGE_MAN_TAIL("fsck.minix(8)")); exit(FSCK_EX_OK); } diff --git a/disk-utils/isosize.c b/disk-utils/isosize.c index 9299663568..bd74e93d03 100644 --- a/disk-utils/isosize.c +++ b/disk-utils/isosize.c @@ -106,8 +106,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -d, --divisor= divide the amount of bytes by \n"), stdout); fputs(_(" -x, --sectors show sector count and size\n"), stdout); - printf(USAGE_HELP_OPTIONS(25)); - printf(USAGE_MAN_TAIL("isosize(8)")); + fprintf(stdout, USAGE_HELP_OPTIONS(25)); + fprintf(stdout, USAGE_MAN_TAIL("isosize(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c index 40f00105e5..866776b7d7 100644 --- a/disk-utils/mkfs.bfs.c +++ b/disk-utils/mkfs.bfs.c @@ -87,9 +87,9 @@ static void __attribute__((__noreturn__)) usage(void) " -l this option is silently ignored\n" " --lock[=] use exclusive device lock (yes, no or nonblock)\n" )); - printf(USAGE_HELP_OPTIONS(21)); + fprintf(out, USAGE_HELP_OPTIONS(21)); - printf(USAGE_MAN_TAIL("mkfs.bfs(8)")); + fprintf(out, USAGE_MAN_TAIL("mkfs.bfs(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/mkfs.c b/disk-utils/mkfs.c index d6fada4ad4..58856d8716 100644 --- a/disk-utils/mkfs.c +++ b/disk-utils/mkfs.c @@ -55,9 +55,9 @@ static void __attribute__((__noreturn__)) usage(void) fprintf(out, _(" number of blocks to be used on the device\n")); fprintf(out, _(" -V, --verbose explain what is being done;\n" " specifying -V more than once will cause a dry-run\n")); - printf(USAGE_HELP_OPTIONS(20)); + fprintf(out, USAGE_HELP_OPTIONS(20)); - printf(USAGE_MAN_TAIL("mkfs(8)")); + fprintf(out, USAGE_MAN_TAIL("mkfs(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c index cdb7b90afc..4823753519 100644 --- a/disk-utils/mkfs.cramfs.c +++ b/disk-utils/mkfs.cramfs.c @@ -126,27 +126,27 @@ struct entry { static void __attribute__((__noreturn__)) usage(void) { fputs(USAGE_HEADER, stdout); - printf(_(" %s [-h] [-v] [-b blksize] [-e edition] [-N endian] [-i file] [-n name] dirname outfile\n"), + fprintf(stdout, _(" %s [-h] [-v] [-b blksize] [-e edition] [-N endian] [-i file] [-n name] dirname outfile\n"), program_invocation_short_name); fputs(USAGE_SEPARATOR, stdout); - puts(_("Make compressed ROM file system.")); + fputs(_("Make compressed ROM file system."), stdout); fputs(USAGE_OPTIONS, stdout); - puts(_( " -v be verbose")); - puts(_( " -E make all warnings errors (non-zero exit status)")); - puts(_( " -b blksize use this blocksize, must equal page size")); - puts(_( " -e edition set edition number (part of fsid)")); - printf(_(" -N endian set cramfs endianness (%s|%s|%s), default %s\n"), "big", "little", "host", "host"); - puts(_( " -i file insert a file image into the filesystem")); - puts(_( " -n name set name of cramfs filesystem")); - printf(_(" -p pad by %d bytes for boot code\n"), PAD_SIZE); - puts(_( " -s sort directory entries (old option, ignored)")); - puts(_( " -z make explicit holes")); - puts(_( " -l[=] use exclusive device lock (yes, no or nonblock)")); - puts(_( " dirname root of the filesystem to be compressed")); - puts(_( " outfile output file")); + fputs(_( " -v be verbose"), stdout); + fputs(_( " -E make all warnings errors (non-zero exit status)"), stdout); + fputs(_( " -b blksize use this blocksize, must equal page size"), stdout); + fputs(_( " -e edition set edition number (part of fsid)"), stdout); + fprintf(stdout, _(" -N endian set cramfs endianness (%s|%s|%s), default %s\n"), "big", "little", "host", "host"); + fputs(_( " -i file insert a file image into the filesystem"), stdout); + fputs(_( " -n name set name of cramfs filesystem"), stdout); + fprintf(stdout, _(" -p pad by %d bytes for boot code\n"), PAD_SIZE); + fputs(_( " -s sort directory entries (old option, ignored)"), stdout); + fputs(_( " -z make explicit holes"), stdout); + fputs(_( " -l[=] use exclusive device lock (yes, no or nonblock)"), stdout); + fputs(_( " dirname root of the filesystem to be compressed"), stdout); + fputs(_( " outfile output file"), stdout); fputs(USAGE_SEPARATOR, stdout); - printf(USAGE_HELP_OPTIONS(16)); - printf(USAGE_MAN_TAIL("mkfs.cramfs(8)")); + fprintf(stdout, USAGE_HELP_OPTIONS(16)); + fprintf(stdout, USAGE_MAN_TAIL("mkfs.cramfs(8)")); exit(MKFS_EX_OK); } diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index 4a8308ade4..334f07fc0a 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -148,8 +148,8 @@ static void __attribute__((__noreturn__)) usage(void) fprintf(out, _( " --lock[=] use exclusive device lock (%s, %s or %s)\n"), "yes", "no", "nonblock"); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(25)); - printf(USAGE_MAN_TAIL("mkfs.minix(8)")); + fprintf(out, USAGE_HELP_OPTIONS(25)); + fprintf(out, USAGE_MAN_TAIL("mkfs.minix(8)")); exit(MKFS_EX_OK); } diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index b6deadf38a..3d988b7376 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -201,9 +201,9 @@ static void __attribute__((__noreturn__)) usage(void) fprintf(out, _(" --lock[=] use exclusive device lock (%s, %s or %s)\n"), "yes", "no", "nonblock"); - printf(USAGE_HELP_OPTIONS(27)); + fprintf(out, USAGE_HELP_OPTIONS(27)); - printf(USAGE_MAN_TAIL("mkswap(8)")); + fprintf(out, USAGE_MAN_TAIL("mkswap(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/partx.c b/disk-utils/partx.c index ac3ef14706..dc6bac33bc 100644 --- a/disk-utils/partx.c +++ b/disk-utils/partx.c @@ -776,13 +776,13 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -v, --verbose verbose mode\n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(22)); + fprintf(out, USAGE_HELP_OPTIONS(22)); fputs(USAGE_COLUMNS, out); for (i = 0; i < NCOLS; i++) fprintf(out, " %10s %s\n", infos[i].name, _(infos[i].help)); - printf(USAGE_MAN_TAIL("partx(8)")); + fprintf(out, USAGE_MAN_TAIL("partx(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/raw.c b/disk-utils/raw.c index b44a581a2d..308910c82a 100644 --- a/disk-utils/raw.c +++ b/disk-utils/raw.c @@ -59,8 +59,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(USAGE_OPTIONS, out); fputs(_(" -q, --query set query mode\n"), out); fputs(_(" -a, --all query all raw devices\n"), out); - printf(USAGE_HELP_OPTIONS(16)); - printf(USAGE_MAN_TAIL("raw(8)")); + fprintf(out, USAGE_HELP_OPTIONS(16)); + fprintf(out, USAGE_MAN_TAIL("raw(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/resizepart.c b/disk-utils/resizepart.c index b2738271e2..df5ee73069 100644 --- a/disk-utils/resizepart.c +++ b/disk-utils/resizepart.c @@ -24,8 +24,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_("Tell the kernel about the new size of a partition.\n"), out); fputs(USAGE_OPTIONS, out); - printf(USAGE_HELP_OPTIONS(16)); - printf(USAGE_MAN_TAIL("resizepart(8)")); + fprintf(out, USAGE_HELP_OPTIONS(16)); + fprintf(out, USAGE_MAN_TAIL("resizepart(8)")); exit(EXIT_SUCCESS); } diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 0e85e63bb3..d8dd8d296a 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -2105,12 +2105,12 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -u, --unit S deprecated, only sector unit is supported\n"), out); fputs(USAGE_SEPARATOR, out); - printf( " -h, --help %s\n", USAGE_OPTSTR_HELP); - printf( " -v, --version %s\n", USAGE_OPTSTR_VERSION); + fprintf(out, " -h, --help %s\n", USAGE_OPTSTR_HELP); + fprintf(out, " -v, --version %s\n", USAGE_OPTSTR_VERSION); list_available_columns(out); - printf(USAGE_MAN_TAIL("sfdisk(8)")); + fprintf(out, USAGE_MAN_TAIL("sfdisk(8)")); exit(EXIT_SUCCESS); } @@ -2474,4 +2474,3 @@ int main(int argc, char *argv[]) DBG(MISC, ul_debug("bye! [rc=%d]", rc)); return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } - diff --git a/disk-utils/swaplabel.c b/disk-utils/swaplabel.c index e6ba7d66d7..b804a92bc3 100644 --- a/disk-utils/swaplabel.c +++ b/disk-utils/swaplabel.c @@ -130,8 +130,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -L, --label