From: Karel Zak Date: Tue, 10 Sep 2019 09:12:38 +0000 (+0200) Subject: setterm: fix --clear X-Git-Tag: v2.35-rc1~219 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Futil-linux.git;a=commitdiff_plain;h=36ce5ebaf4348afe2abbb3e3e0c0bd04d8bec283 setterm: fix --clear * make argument optional as in the original version * fix typo (reset -> rest) Addresses: https://github.com/karelzak/util-linux/issues/861 Signed-off-by: Karel Zak --- diff --git a/term-utils/setterm.1 b/term-utils/setterm.1 index 1685657b23..75d3b5b91e 100644 --- a/term-utils/setterm.1 +++ b/term-utils/setterm.1 @@ -115,7 +115,7 @@ Turns bold (extra bright) mode on or off. Except on a virtual console, .B \-\-bold off turns off all attributes (bold, half-brightness, blink, reverse). .TP -\fB\-\-clear\fP [\fBall\fP|\fBrest\fP] +\fB\-\-clear\fP[=\fBall\fP|\fBrest\fP] Without an argument or with the argument .BR all , the entire screen is cleared and the cursor is set to the home position, diff --git a/term-utils/setterm.c b/term-utils/setterm.c index 14fbafb107..95cef0241b 100644 --- a/term-utils/setterm.c +++ b/term-utils/setterm.c @@ -406,7 +406,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" --blink [on|off] blink\n"), out); fputs(_(" --underline [on|off] underline\n"), out); fputs(_(" --reverse [on|off] swap foreground and background colors\n"), out); - fputs(_(" --clear [all|rest] clear screen and set cursor position\n"), out); + fputs(_(" --clear [=] clear screen and set cursor position\n"), out); fputs(_(" --tabs [...] set these tab stop positions, or show them\n"), out); fputs(_(" --clrtabs [...] clear these tab stop positions, or all\n"), out); fputs(_(" --regtabs [1-160] set a regular tab stop interval\n"), out); @@ -497,7 +497,7 @@ static void parse_option(struct setterm_control *ctl, int ac, char **av) {"reverse", required_argument, NULL, OPT_REVERSE}, {"underline", required_argument, NULL, OPT_UNDERLINE}, {"store", no_argument, NULL, OPT_STORE}, - {"clear", required_argument, NULL, OPT_CLEAR}, + {"clear", optional_argument, NULL, OPT_CLEAR}, {"tabs", optional_argument, NULL, OPT_TABS}, {"clrtabs", optional_argument, NULL, OPT_CLRTABS}, {"regtabs", optional_argument, NULL, OPT_REGTABS}, @@ -613,8 +613,11 @@ static void parse_option(struct setterm_control *ctl, int ac, char **av) break; case OPT_CLEAR: ctl->opt_clear = set_opt_flag(ctl->opt_clear); - ctl->opt_cl_all = parse_switch(optarg, _("argument error"), - "all", "reset", NULL); + if (optarg) + ctl->opt_cl_all = parse_switch(optarg, _("argument error"), + "all", "rest", NULL); + else + ctl->opt_cl_all = 1; break; case OPT_TABS: ctl->opt_tabs = set_opt_flag(ctl->opt_tabs);