blob: 3cc16257ba3d81f0883041b21d274e1f26c68ee3 [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersen2b69c401999-10-05 22:58:32 +00002/*
3 * Mini clear implementation for busybox
4 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Eric Andersen2b69c401999-10-05 22:58:32 +00006 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02007 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Eric Andersen2b69c401999-10-05 22:58:32 +00008 */
Denys Vlasenko6d932992016-11-23 10:39:27 +01009//config:config CLEAR
Denys Vlasenko4eed2c62017-07-18 22:01:24 +020010//config: bool "clear (tiny)"
Denys Vlasenko6d932992016-11-23 10:39:27 +010011//config: default y
12//config: help
Denys Vlasenko72089cf2017-07-21 09:50:55 +020013//config: This program clears the terminal screen.
Denys Vlasenko6d932992016-11-23 10:39:27 +010014
Denys Vlasenko819b47a2017-08-03 03:29:32 +020015//applet:IF_CLEAR(APPLET_NOFORK(clear, clear, BB_DIR_USR_BIN, BB_SUID_DROP, clear))
Denys Vlasenko6d932992016-11-23 10:39:27 +010016
17//kbuild:lib-$(CONFIG_CLEAR) += clear.o
Pere Orga55068c42011-03-27 23:42:28 +020018
19//usage:#define clear_trivial_usage
20//usage: ""
21//usage:#define clear_full_usage "\n\n"
22//usage: "Clear screen"
23
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000024#include "libbb.h"
Eric Andersencc8ed391999-10-05 16:24:54 +000025
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000026int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +000027int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
Eric Andersencc8ed391999-10-05 16:24:54 +000028{
Denys Vlasenkod9a3e892010-05-16 23:42:13 +020029 /* home; clear to the end of screen */
Denys Vlasenko729ecb82010-06-07 14:14:26 +020030 return full_write1_str("\033[H""\033[J") != 6;
Eric Andersencc8ed391999-10-05 16:24:54 +000031}