blob: b360d34d94a0b60130724b368c403735203c7e81 [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
10//config: bool "clear"
11//config: default y
12//config: help
13//config: This program clears the terminal screen.
14
15//applet:IF_CLEAR(APPLET(clear, BB_DIR_USR_BIN, BB_SUID_DROP))
16
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}