1 /* vi: set sw=4 ts=4: */
3 * Mini reset implementation for busybox
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 //config: bool "reset (275 bytes)"
14 //config: This program is used to reset the terminal screen, if it
15 //config: gets messed up.
17 //applet:IF_RESET(APPLET_NOEXEC(reset, reset, BB_DIR_USR_BIN, BB_SUID_DROP, reset))
19 //kbuild:lib-$(CONFIG_RESET) += reset.o
21 //usage:#define reset_trivial_usage
23 //usage:#define reset_full_usage "\n\n"
24 //usage: "Reset the screen"
26 /* "Standard" version of this tool is in ncurses package */
33 int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
36 int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
37 int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
39 static const char *const args[] = {
43 /* no options, no getopt */
45 if (/*isatty(STDIN_FILENO) &&*/ isatty(STDOUT_FILENO)) {
46 /* See 'man 4 console_codes' for details:
48 * "ESC ( B" -- Select G0 Character Set (B = US)
49 * "ESC [ m" -- Reset all display attributes
50 * "ESC [ J" -- Erase to the end of screen
51 * "ESC [ ? 25 h" -- Make cursor visible
53 printf(ESC"c" ESC"(B" ESC"[m" ESC"[J" ESC"[?25h");
54 /* http://bugs.busybox.net/view.php?id=1414:
55 * people want it to reset echo etc: */
57 return stty_main(2, (char**)args);
59 /* Make sure stdout gets drained before we execvp */
61 execvp("stty", (char**)args);