diff options
author | Karel Zak | 2019-04-16 15:14:13 +0200 |
---|---|---|
committer | Karel Zak | 2019-04-16 15:14:13 +0200 |
commit | 2c308875a7fa1aaa44892c368f6b37bcfcb8879a (patch) | |
tree | 157ea7afca59059676dbcc25133dd196d1e45fb8 /term-utils | |
parent | include/c: add print_version() macro (diff) | |
download | kernel-qcow2-util-linux-2c308875a7fa1aaa44892c368f6b37bcfcb8879a.tar.gz kernel-qcow2-util-linux-2c308875a7fa1aaa44892c368f6b37bcfcb8879a.tar.xz kernel-qcow2-util-linux-2c308875a7fa1aaa44892c368f6b37bcfcb8879a.zip |
misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils')
-rw-r--r-- | term-utils/mesg.c | 6 | ||||
-rw-r--r-- | term-utils/script.c | 8 | ||||
-rw-r--r-- | term-utils/scriptreplay.c | 6 | ||||
-rw-r--r-- | term-utils/setterm.c | 6 | ||||
-rw-r--r-- | term-utils/wall.c | 6 | ||||
-rw-r--r-- | term-utils/write.c | 5 |
6 files changed, 17 insertions, 20 deletions
diff --git a/term-utils/mesg.c b/term-utils/mesg.c index 608f3cf61..57d53379f 100644 --- a/term-utils/mesg.c +++ b/term-utils/mesg.c @@ -102,16 +102,16 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((ch = getopt_long(argc, argv, "vVh", longopts, NULL)) != -1) switch (ch) { case 'v': verbose = TRUE; break; + case 'V': - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/term-utils/script.c b/term-utils/script.c index 7692f91e2..c7bc1d6f2 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -793,7 +793,7 @@ int main(int argc, char **argv) setlocale(LC_NUMERIC, "C"); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); script_init_debug(); @@ -825,13 +825,11 @@ int main(int argc, char **argv) ctl.tname = optarg; ctl.timing = 1; break; + case 'V': - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); - break; + print_version(EXIT_SUCCESS); case 'h': usage(); - break; default: errtryhelp(EXIT_FAILURE); } diff --git a/term-utils/scriptreplay.c b/term-utils/scriptreplay.c index 7b59b6e24..926e56f11 100644 --- a/term-utils/scriptreplay.c +++ b/term-utils/scriptreplay.c @@ -151,7 +151,7 @@ main(int argc, char *argv[]) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((ch = getopt_long(argc, argv, "t:s:d:m:Vh", longopts, NULL)) != -1) switch(ch) { @@ -169,9 +169,9 @@ main(int argc, char *argv[]) maxdelayopt = TRUE; maxdelay = getnum(optarg); break; + case 'V': - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/term-utils/setterm.c b/term-utils/setterm.c index 0d4b81292..14fbafb10 100644 --- a/term-utils/setterm.c +++ b/term-utils/setterm.c @@ -673,9 +673,9 @@ static void parse_option(struct setterm_control *ctl, int ac, char **av) ctl->opt_bfreq = set_opt_flag(ctl->opt_bfreq); ctl->opt_bfreq_f = parse_bfreq(av, optarg, &optind); break; + case OPT_VERSION: - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); + print_version(EXIT_SUCCESS); case OPT_HELP: usage(); default: @@ -1173,7 +1173,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); if (argc < 2) { warnx(_("bad usage")); diff --git a/term-utils/wall.c b/term-utils/wall.c index ce5363c7e..c606e6347 100644 --- a/term-utils/wall.c +++ b/term-utils/wall.c @@ -202,7 +202,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((ch = getopt_long(argc, argv, "nt:g:Vh", longopts, NULL)) != -1) { switch (ch) { @@ -220,9 +220,9 @@ int main(int argc, char **argv) case 'g': group_buf = init_group_workspace(optarg); break; + case 'V': - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/term-utils/write.c b/term-utils/write.c index bd64fc281..3436fbda2 100644 --- a/term-utils/write.c +++ b/term-utils/write.c @@ -308,13 +308,12 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (c) { case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); default: |