From 7b0d88b2dff9b635d9ff69f6d51b6832c1ca4c40 Mon Sep 17 00:00:00 2001 From: Miguel Date: Sat, 18 Aug 2018 13:23:53 +0200 Subject: cleaning up syscalls and playing with new pipes --- userspace/foolshell.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'userspace/foolshell.c') diff --git a/userspace/foolshell.c b/userspace/foolshell.c index a502f47..7247871 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -71,11 +71,27 @@ int main(int argc, char **argv) //char *buf=malloc(256); char *buf=calloc(sizeof(char),256); + printf("setvbuf returned %i\n",setvbuf(stdin,NULL,_IONBF,0)); + while(1) { prompt(); - fgets(buf,255,stdin); - buf[strlen(buf)-1]=0; // remove \n + int bl=0; + + while(1) + { + char c=fgetc(stdin); + putc(c,stdout); + if(c=='\n')break; + + + buf[bl]=c; + buf[bl+1]='\0'; + bl++; + } + + //fgets(buf,255,stdin); + //buf[strlen(buf)-1]=0; // remove \n process(buf); } @@ -125,7 +141,6 @@ char **tokenize(char *buf) int process(char *buf) { - char **token=tokenize(buf); char *command=token[0]; // puts(command); -- cgit v1.2.3