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.
10 /* "Standard" version of this tool is in ncurses package */
13 //config: bool "reset (275 bytes)"
16 //config: This program is used to reset the terminal screen, if it
17 //config: gets messed up.
19 //applet:IF_RESET(APPLET_NOEXEC(reset, reset, BB_DIR_USR_BIN, BB_SUID_DROP, reset))
21 //kbuild:lib-$(CONFIG_RESET) += reset.o
23 //usage:#define reset_trivial_usage
25 //usage:#define reset_full_usage "\n\n"
26 //usage: "Reset the screen"
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 [ 0 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"[0m" 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);