8 |
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
9 |
*/ |
*/ |
10 |
|
|
11 |
/* no options, no getopt */ |
#include "libbb.h" |
12 |
|
|
13 |
#include <stdio.h> |
/* BTW, which "standard" package has this utility? It doesn't seem |
14 |
#include <stdlib.h> |
* to be ncurses, coreutils, console-tools... then what? */ |
|
#include <unistd.h> |
|
|
#include "busybox.h" |
|
15 |
|
|
16 |
int reset_main(int argc, char **argv) |
#if ENABLE_STTY |
17 |
|
int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
18 |
|
#endif |
19 |
|
|
20 |
|
int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
21 |
|
int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
22 |
{ |
{ |
23 |
if (isatty(1)) { |
static const char *const args[] = { |
24 |
|
"stty", "sane", NULL |
25 |
|
}; |
26 |
|
|
27 |
|
/* no options, no getopt */ |
28 |
|
|
29 |
|
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) { |
30 |
/* See 'man 4 console_codes' for details: |
/* See 'man 4 console_codes' for details: |
31 |
* "ESC c" -- Reset |
* "ESC c" -- Reset |
32 |
* "ESC ( K" -- Select user mapping |
* "ESC ( K" -- Select user mapping |
35 |
* "ESC [ ? 25 h" -- Make cursor visible. |
* "ESC [ ? 25 h" -- Make cursor visible. |
36 |
*/ |
*/ |
37 |
printf("\033c\033(K\033[J\033[0m\033[?25h"); |
printf("\033c\033(K\033[J\033[0m\033[?25h"); |
38 |
|
/* http://bugs.busybox.net/view.php?id=1414: |
39 |
|
* people want it to reset echo etc: */ |
40 |
|
#if ENABLE_STTY |
41 |
|
return stty_main(2, (char**)args); |
42 |
|
#else |
43 |
|
execvp("stty", (char**)args); |
44 |
|
#endif |
45 |
} |
} |
46 |
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
47 |
} |
} |
|
|
|