diff options
| author | Miguel <m.i@gmx.at> | 2018-09-03 15:18:16 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-09-03 15:18:16 +0200 |
| commit | 7eb87bf3f3fa6226657a7106eb255cbfa97758d2 (patch) | |
| tree | 2d7d2280d32180d18796999bf7687ebe5bf208df /userspace/foolshell.c | |
| parent | 76b3da6022310dd8edbbbfdf4f73f1696a559853 (diff) | |
big renaming
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); } |
