summaryrefslogtreecommitdiff
path: root/userspace/cat.c
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-19 01:52:14 +0200
committerMiguel <m.i@gmx.at>2018-09-19 01:52:14 +0200
commit1e08b64b43bf9c50b644da3f76d5a8bcc73f62da (patch)
tree53aca729b7faeb781b04b9c62a7b1b13efa21991 /userspace/cat.c
parent2d91384197847a7e8fe2c3f548918a8277d3086d (diff)
addding sysfs and pipes etc
Diffstat (limited to 'userspace/cat.c')
-rw-r--r--userspace/cat.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/userspace/cat.c b/userspace/cat.c
index 5b419ca..d0b018b 100644
--- a/userspace/cat.c
+++ b/userspace/cat.c
@@ -5,8 +5,17 @@ int main(int argc, char **argv)
FILE *f;
if(argc>1){
char buf[256];
- sprintf(buf,"%s/%s",getenv("PWD"),argv[1]);
- f=fopen(buf,"r");
+ if(argv[1][0]!='/')
+ {
+ sprintf(buf,"%s/%s",getenv("PWD"),argv[1]);
+ printf("cat %s\n",buf);
+ f=fopen(buf,"r");
+ }
+ else
+ {
+ printf("cat %s\n",argv[1]);
+ f=fopen(argv[1],"r");
+ }
}
else f=stdin;
@@ -15,14 +24,10 @@ int main(int argc, char **argv)
char c;
- printf("-- reading from file byte by byte --\n\n");
-
while(fread(&c,1,1,f))
{
printf("%c",c);
}
- printf("\n-- no more data on this file --\n");
-
return 0;
}