summaryrefslogtreecommitdiff
path: root/userspace/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'userspace/grep.c')
-rw-r--r--userspace/grep.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/userspace/grep.c b/userspace/grep.c
index c37392f..68d5b7a 100644
--- a/userspace/grep.c
+++ b/userspace/grep.c
@@ -3,15 +3,17 @@
int main(int argc, char **argv)
{
- while(1)
- {
- char buf[256];
- int l=fread(buf,1,255,stdin);
- if(l==0)break;
- buf[l]=0;
- printf("grep: %s",buf);
+ FILE *in=stdin;
+ FILE *out=stdout;
- }
+ while(1)
+ {
+ char buf[2];
+ int l=fread(buf,1,1,in);
+ if(l==0)break;
+ buf[l]=0;
+ fwrite(buf,1,l,out);
+ }
- return EXIT_SUCCESS;
+ return EXIT_SUCCESS;
}