From 955aa159ff26634751116056c24b284c395b7cc7 Mon Sep 17 00:00:00 2001 From: gene Date: Fri, 7 Mar 1997 21:54:48 +0000 Subject: [PATCH] Integrate clear into tput itself with silly argv munching. --- usr.bin/tput/Makefile | 7 ++----- usr.bin/tput/tput.c | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/usr.bin/tput/Makefile b/usr.bin/tput/Makefile index afa5882364e..8a21bd6f2c8 100644 --- a/usr.bin/tput/Makefile +++ b/usr.bin/tput/Makefile @@ -1,13 +1,10 @@ -# $OpenBSD: Makefile,v 1.3 1996/12/08 14:32:35 downsj Exp $ +# $OpenBSD: Makefile,v 1.4 1997/03/07 21:54:48 gene Exp $ # $NetBSD: Makefile,v 1.3 1994/12/07 08:49:07 jtc Exp $ PROG= tput DPADD= ${LIBTERMCAP} LDADD= -ltermcap MLINKS= tput.1 clear.1 - -beforeinstall: - ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/clear.sh ${DESTDIR}/usr/bin/clear +LINKS= ${BINDIR}/tput ${BINDIR}/clear .include diff --git a/usr.bin/tput/tput.c b/usr.bin/tput/tput.c index 2f168654f5d..cea5160ff31 100644 --- a/usr.bin/tput/tput.c +++ b/usr.bin/tput/tput.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tput.c,v 1.3 1997/01/15 23:43:23 millert Exp $ */ +/* $OpenBSD: tput.c,v 1.4 1997/03/07 21:54:48 gene Exp $ */ /* $NetBSD: tput.c,v 1.8 1995/08/31 22:11:37 jtc Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)tput.c 8.3 (Berkeley) 4/28/95"; #endif -static char rcsid[] = "$OpenBSD: tput.c,v 1.3 1997/01/15 23:43:23 millert Exp $"; +static char rcsid[] = "$OpenBSD: tput.c,v 1.4 1997/03/07 21:54:48 gene Exp $"; #endif /* not lint */ #include @@ -69,7 +69,7 @@ main(argc, argv) extern char *optarg; extern int optind; int ch, exitval, n; - char *cptr, *p, *term, buf[1024], tbuf[1024]; + char *argv0, *cptr, *p, *term, buf[1024], tbuf[1024]; term = NULL; while ((ch = getopt(argc, argv, "T:")) != -1) @@ -81,14 +81,23 @@ main(argc, argv) default: usage(); } + if ((argv0 = (char *)strrchr(argv[0], '/')) != NULL) + argv0++; + else + argv0 = argv[0]; argc -= optind; argv += optind; + if (!term && !(term = getenv("TERM"))) errx(2, "no terminal type specified and no TERM environmental variable."); if (tgetent(tbuf, term) != 1) err(2, "tgetent failure"); setospeed(); + if (strcmp(argv0, "clear") == 0) { + *argv = "clear"; + *(argv+1) = NULL; + } for (exitval = 0; (p = *argv) != NULL; ++argv) { switch (*p) { case 'c': -- 2.20.1