diff options
Diffstat (limited to 'userspace/foolshell.c')
| -rw-r--r-- | userspace/foolshell.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 38a6e55..86c083c 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -66,10 +66,8 @@ int main(int argc, char **argv) if(!silent)hello(); - //char *buf=malloc(256); char *buf=calloc(sizeof(char),256); -// printf("setvbuf returned %i\n", setvbuf(stdin,NULL,_IONBF,0); while(1) @@ -80,17 +78,25 @@ int main(int argc, char **argv) while(1) { char c=fgetc(stdin); - putc(c,stdout); - if(c=='\n')break; - - buf[bl]=c; - buf[bl+1]='\0'; - bl++; + if(c=='\b') + { + if(bl==0)continue; + buf[--bl]='\0'; + putc(c,stdout); + } + else + { + putc(c,stdout); + if(c=='\n')break; + buf[bl]=c; + buf[++bl]='\0'; + } } //fgets(buf,255,stdin); //buf[strlen(buf)-1]=0; // remove \n + printf("[%s]",buf); process(buf); } |
