Add && and || support to tokenizer

This commit is contained in:
ridiculousfish
2018-03-01 12:56:15 -08:00
parent a5dd96558f
commit 8ded041352
5 changed files with 56 additions and 45 deletions

View File

@@ -528,16 +528,28 @@ maybe_t<tok_t> tokenizer_t::tok_next() {
break;
}
case L'&': {
result.type = TOK_BACKGROUND;
result.length = 1;
this->buff++;
if (this->buff[1] == L'&') {
result.type = TOK_ANDAND;
result.length = 2;
this->buff += 2;
} else {
result.type = TOK_BACKGROUND;
result.length = 1;
this->buff++;
}
break;
}
case L'|': {
result.type = TOK_PIPE;
result.redirected_fd = 1;
result.length = 1;
this->buff++;
if (this->buff[1] == L'|') {
result.type = TOK_OROR;
result.length = 2;
this->buff += 2;
} else {
result.type = TOK_PIPE;
result.redirected_fd = 1;
result.length = 1;
this->buff++;
}
break;
}
case L'>':