X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=console-tools%2Freset.c;h=792618f5cb88d02b608fa8fd707cc2c934d87b23;hb=97551974485a8680299560af8863023dfb9634af;hp=69b1e846a204116f9b4151f0b8850cde11b12458;hpb=cb81e6484d1f50ec2761f6294722407b14add525;p=oweals%2Fbusybox.git diff --git a/console-tools/reset.c b/console-tools/reset.c index 69b1e846a..792618f5c 100644 --- a/console-tools/reset.c +++ b/console-tools/reset.c @@ -2,7 +2,7 @@ /* * Mini reset implementation for busybox * - * Copyright (C) 1999-2003 by Erik Andersen + * Copyright (C) 1999-2004 by Erik Andersen * Written by Erik Andersen and Kent Robotti * * This program is free software; you can redistribute it and/or modify @@ -21,13 +21,25 @@ * */ +/* no options, no getopt */ + #include #include +#include #include "busybox.h" -extern int reset_main(int argc, char **argv) +int reset_main(int argc, char **argv) { - printf("\033[?25h\033c\033[J"); - return EXIT_SUCCESS; + if (isatty(1)) { + /* See 'man 4 console_codes' for details: + * "ESC c" -- Reset + * "ESC ( K" -- Select user mapping + * "ESC [ J" -- Erase display + * "ESC [ 0 m" -- Reset all display attributes + * "ESC [ ? 25 h" -- Make cursor visible. + */ + printf("\033c\033(K\033[J\033[0m\033[?25h"); + } + return EXIT_SUCCESS; }