]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
setterm: fix --clear
authorKarel Zak <kzak@redhat.com>
Tue, 10 Sep 2019 09:12:38 +0000 (11:12 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 10 Sep 2019 09:12:38 +0000 (11:12 +0200)
* 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 <kzak@redhat.com>
term-utils/setterm.1
term-utils/setterm.c

index 1685657b2303f68c188770825f8ca04994f24391..75d3b5b91ed30fd5f7c039f6361054fb7037345b 100644 (file)
@@ -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,
index 14fbafb1073d255b648989687b1fc5e7c3b9bd13..95cef0241b648f53ea3042a65efc8dcf8a9b43f3 100644 (file)
@@ -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         [=<all|rest>]        clear screen and set cursor position\n"), out);
        fputs(_(" --tabs          [<number>...]     set these tab stop positions, or show them\n"), out);
        fputs(_(" --clrtabs       [<number>...]     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);