* Fixed the embarrasing failure of the -p opition in the logger app. -erik
* Re-worked the whole source tree a bit so it will compile under glibc 2.0.7
with the 2.0.x Linux kernel.
+ * Added 'grep -q' thanks to a patch from "Konstantin Boldyshev"
+ <konst@voshod.com>.
-Erik Andersen
*
*/
+/*
+ 18-Dec-1999 Konstantin Boldyshev <konst@voshod.com>
+
+ + -q option (be quiet)
+ + exit code depending on grep result (TRUE or FALSE)
+ (useful for scripts)
+*/
+
#include "internal.h"
#include "regexp.h"
#include <stdio.h>
"OPTIONS:\n"
"\t-h\tsuppress the prefixing filename on output\n"
"\t-i\tignore case distinctions\n"
-"\t-n\tprint line number with output lines\n\n"
+"\t-n\tprint line number with output lines\n"
+"\t-q\tbe quiet\n\n"
#if defined BB_REGEXP
"This version of grep matches full regular expresions.\n";
#else
"This version of grep matches strings (not regular expresions).\n";
#endif
+static int match = FALSE, beQuiet = FALSE;
static void do_grep(FILE *fp, char* needle, char *fileName, int tellName, int ignoreCase, int tellLine)
{
if (tellLine==TRUE)
printf ("%ld:", line);
- fputs (haystack, stdout);
+ if (beQuiet==FALSE)
+ fputs (haystack, stdout);
+
+ match = TRUE;
}
}
}
tellLine = TRUE;
break;
+ case 'q':
+ beQuiet = TRUE;
+ break;
+
default:
usage(grep_usage);
}
fclose (fp);
}
}
- exit( TRUE);
+ exit(match);
}
*
*/
+/*
+ 18-Dec-1999 Konstantin Boldyshev <konst@voshod.com>
+
+ + -q option (be quiet)
+ + exit code depending on grep result (TRUE or FALSE)
+ (useful for scripts)
+*/
+
#include "internal.h"
#include "regexp.h"
#include <stdio.h>
"OPTIONS:\n"
"\t-h\tsuppress the prefixing filename on output\n"
"\t-i\tignore case distinctions\n"
-"\t-n\tprint line number with output lines\n\n"
+"\t-n\tprint line number with output lines\n"
+"\t-q\tbe quiet\n\n"
#if defined BB_REGEXP
"This version of grep matches full regular expresions.\n";
#else
"This version of grep matches strings (not regular expresions).\n";
#endif
+static int match = FALSE, beQuiet = FALSE;
static void do_grep(FILE *fp, char* needle, char *fileName, int tellName, int ignoreCase, int tellLine)
{
if (tellLine==TRUE)
printf ("%ld:", line);
- fputs (haystack, stdout);
+ if (beQuiet==FALSE)
+ fputs (haystack, stdout);
+
+ match = TRUE;
}
}
}
tellLine = TRUE;
break;
+ case 'q':
+ beQuiet = TRUE;
+ break;
+
default:
usage(grep_usage);
}
fclose (fp);
}
}
- exit( TRUE);
+ exit(match);
}