summaryrefslogtreecommitdiff
path: root/src/user/app/shell/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/shell/parser.c')
-rw-r--r--src/user/app/shell/parser.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/user/app/shell/parser.c b/src/user/app/shell/parser.c
index bd70350..878202d 100644
--- a/src/user/app/shell/parser.c
+++ b/src/user/app/shell/parser.c
@@ -13,11 +13,16 @@ static char skipspace(char **sp) {
return *s;
}
+static bool isspecial(char c) {
+ return c == '>' || c == '#';
+}
+
static char *parg(char **sp) {
char *s = *sp;
char *res = NULL;
if (skipspace(&s)) {
+ // TODO incorrectly handles strings like a"b"
switch (*s) {
case '"':
s++;
@@ -27,8 +32,13 @@ static char *parg(char **sp) {
break;
default:
res = s;
- while (*s && !isspace(*s) && *s != '>')
+ while (*s && !isspace(*s) && !isspecial(*s))
s++;
+ if (*s == '#') {
+ *s = '\0'; /* end parsing early */
+ if (res == s) /* don't output an empty arg */
+ res = NULL;
+ }
break;
}
if (*s) *s++ = '\0';