mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:37:35 +00:00
Add a naive /bin/fgrep for testing pipes.
This commit is contained in:
parent
d5d45d1088
commit
18e3ddf605
8 changed files with 56 additions and 8 deletions
20
Userland/fgrep.cpp
Normal file
20
Userland/fgrep.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("usage: fgrep <str>\n");
|
||||
return 0;
|
||||
}
|
||||
for (;;) {
|
||||
char buf[4096];
|
||||
fgets(buf, sizeof(buf), stdin);
|
||||
if (feof(stdin))
|
||||
return 0;
|
||||
if (strstr(buf, argv[1]))
|
||||
write(1, buf, strlen(buf));
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue