[BusyBox] [PATCH] Fix busybox head, tail to take old -n argument (was: Re: unable to run hello world on ARM920T processor)
dank at kegel.com
dank at kegel.com
Tue Jul 16 23:12:03 UTC 2002
Hari v <armharry at yahoo.com> wrote:
> thanks. yes i enabled the features in Config.h.
> Now the earlier messages like unset is missing.
> But how to remove head:invalid option -- 1
Apply the following patch, perhaps? That should
let the Java startup script do its head -1 successfully.
- Dan
-------------- next part --------------
--- busybox-0.60.2/tail.c.orig Tue Jul 16 22:32:00 2002
+++ busybox-0.60.2/tail.c Tue Jul 16 22:46:19 2002
@@ -22,6 +22,7 @@
*/
+#include <ctype.h>
#include <fcntl.h>
#include <getopt.h>
#include <string.h>
@@ -67,6 +68,13 @@
int *fds, nfiles = 0, status = EXIT_SUCCESS, nread, nwrite, seen = 0;
char *s, *start, *end, buf[BUFSIZ];
int i, opt;
+
+ /* Support traditional -%d option if first; needed by many scripts */
+ if ((argc > 1) && (argv[1][0] == '-') && isdigit(argv[1][1])) {
+ count = atoi(argv[1]+1);
+ argc--;
+ argv++;
+ }
while ((opt = getopt(argc, argv, "c:fhn:q:s:v")) > 0) {
switch (opt) {
--- busybox-0.60.2/head.c.orig Tue Jul 16 22:49:23 2002
+++ busybox-0.60.2/head.c Tue Jul 16 22:50:07 2002
@@ -21,6 +21,7 @@
*
*/
+#include <ctype.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
@@ -46,6 +47,13 @@
{
FILE *fp;
int need_headers, opt, len = 10, status = EXIT_SUCCESS;
+
+ /* Support traditional -%d option if first; needed by many scripts */
+ if ((argc > 1) && (argv[1][0] == '-') && isdigit(argv[1][1])) {
+ len = atoi(argv[1]+1);
+ argc--;
+ argv++;
+ }
/* parse argv[] */
while ((opt = getopt(argc, argv, "n:")) > 0) {
More information about the busybox
mailing list