X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/383318a4381375add624530005a803bd934ceec7..bdc143a7aa3f51a46eceec62b0b364599533fa21:/lunaix-os/usr/sh/sh.c diff --git a/lunaix-os/usr/sh/sh.c b/lunaix-os/usr/sh/sh.c index 2ac473a..c2c8347 100644 --- a/lunaix-os/usr/sh/sh.c +++ b/lunaix-os/usr/sh/sh.c @@ -132,6 +132,27 @@ sh_exec(const char** argv) waitpid(p, NULL, 0); } +static char* +sanity_filter(char* buf) +{ + int off = 0, i = 0; + char c; + do { + c = buf[i]; + + if ((32 <= c && c <= 126) || !c) { + buf[i - off] = c; + } + else { + off++; + } + + i++; + } while(c); + + return buf; +} + void sh_loop() { @@ -157,6 +178,7 @@ sh_loop() } buf[sz] = '\0'; + sanity_filter(buf); // currently, this shell only support single argument if (!parse_cmdline(buf, argv)) {