Patch: tail 'from_top' feature broken

Gabriel L. Somlo somlo at cmu.edu
Wed Dec 20 20:42:29 UTC 2006


Dennis & All,

As of svn 17022, 'tail +lineno' or 'tail -n +lineno' is broken. The
optarg '+lineno' gets passed to xatol_sfx(), which bitches about the
leading '+' character and kicks us out.

Not sure whether or not that's the desired behavior of xatol_sfx(), but
the enclosed patch to tail.c fixes the issue.

Please apply. Thanks,
Gabriel


diff -NarU5 busybox-svn-17022.orig/coreutils/tail.c busybox-svn-17022/coreutils/tail.c
--- busybox-svn-17022.orig/coreutils/tail.c	2006-12-20 15:33:24.000000000 -0500
+++ busybox-svn-17022/coreutils/tail.c	2006-12-20 15:36:00.000000000 -0500
@@ -122,17 +122,18 @@
 				/* FALLS THROUGH */
 			case 'n':
 #if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
 			GET_COUNT:
 #endif
-				count = xatol_sfx(optarg, tail_suffixes);
-				/* Note: Leading whitespace is an error trapped above. */
 				if (*optarg == '+') {
+					++optarg;
 					from_top = 1;
 				} else {
 					from_top = 0;
 				}
+				count = xatol_sfx(optarg, tail_suffixes);
+				/* Note: Leading whitespace is an error trapped above. */
 				if (count < 0) {
 					count = -count;
 				}
 				break;
 #if ENABLE_FEATURE_FANCY_TAIL



More information about the busybox mailing list