Refactor clear(1) - ubase - suckless linux base utils | |
git clone git://git.suckless.org/ubase | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 7b27c7f87c01b00b6a3e5cd7a60fb832681d5ccc | |
parent b6669b5f196275bcf205abe5904b63bcd9213011 | |
Author: FRIGN <[email protected]> | |
Date: Mon, 7 Sep 2015 12:33:16 +0200 | |
Refactor clear(1) | |
Adopting best practices(tm) we developed with sbase. | |
Diffstat: | |
M clear.1 | 2 +- | |
M clear.c | 16 +++++++++++++++- | |
2 files changed, 16 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/clear.1 b/clear.1 | |
@@ -8,4 +8,4 @@ | |
.Nm | |
.Sh DESCRIPTION | |
.Nm | |
-clears the screen | |
+clears the screen. | |
diff --git a/clear.c b/clear.c | |
@@ -2,9 +2,23 @@ | |
#include <stdio.h> | |
#include <stdlib.h> | |
+#include "util.h" | |
+ | |
+static void | |
+usage(void) | |
+{ | |
+ eprintf("usage: %s\n", argv0); | |
+} | |
+ | |
int | |
-main(void) | |
+main(int argc, char *argv[]) | |
{ | |
+ argv0 = argv[0], argc--, argv++; | |
+ | |
+ if (argc) | |
+ usage(); | |
+ | |
printf("\x1b[2J\x1b[H"); | |
+ | |
return 0; | |
} |