[BusyBox] [PATCH] support "tail +nnn"

Dan Kegel dank at kegel.com
Sun Dec 22 21:59:03 UTC 2002


(Apologies if this has been posted before.)

Some shell scripts from very big, very popular companies rely on the obsolete syntax
   tail +10 foo.txt

Turns out this is very easy to implement; here's a patch against
busybox 0.60.5.  Please review, and if it's ok, please apply.

Thanks!
- Dan

--- busybox-0.60.5/tail.c.orig	Fri Dec 20 13:27:46 2002
+++ busybox-0.60.5/tail.c	Fri Dec 20 13:29:40 2002
@@ -69,8 +69,10 @@
  	char *s, *start, *end, buf[BUFSIZ];
  	int i, opt;

-	if (( argc >= 2 ) && ( argv [1][0] == '-' ) && isdigit ( argv [1][1] )) {
+	if (( argc >= 2 ) && ( argv [1][0] == '-' || argv [1][0] == '+' )
+	&&  isdigit ( argv [1][1] )) {
  		count = atoi ( &argv [1][1] );
+		from_top = (argv[1][0] == '+');
  		optind = 2;
  	}


-- 
Dan Kegel
Linux User #78045
http://www.kegel.com




More information about the busybox mailing list