aboutsummaryrefslogtreecommitdiffhomepage
path: root/tokenizer.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-09-11 14:22:16 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-09-11 14:22:16 -0700
commit46452e7634b658f2a5f704890ae9d77d932d4610 (patch)
treea1be8c0177fcef8808eb728b341cadc63f8ed8d3 /tokenizer.cpp
parentee3b355c3445368adf524af79c99244a77e46169 (diff)
Improve error messages for double square brackets -
Diffstat (limited to 'tokenizer.cpp')
-rw-r--r--tokenizer.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/tokenizer.cpp b/tokenizer.cpp
index 831197ee..4521c164 100644
--- a/tokenizer.cpp
+++ b/tokenizer.cpp
@@ -37,6 +37,12 @@ segments.
#define PARAN_ERROR _( L"Unexpected end of string, parenthesis do not match" )
/**
+ Error string for mismatched square brackets
+*/
+#define SQUARE_BRACKET_ERROR _( L"Unexpected end of string, square brackets do not match" )
+
+
+/**
Error string for invalid redirections
*/
#define REDIRECT_ERROR _( L"Invalid input/output redirection" )
@@ -237,7 +243,6 @@ static void read_string(tokenizer_t *tok)
while (1)
{
-
if (!myal(*tok->buff))
{
if (*tok->buff == L'\\')
@@ -390,7 +395,19 @@ static void read_string(tokenizer_t *tok)
if ((!tok->accept_unfinished) && (mode != mode_regular_text))
{
- TOK_CALL_ERROR(tok, TOK_UNTERMINATED_SUBSHELL, PARAN_ERROR);
+ switch (mode)
+ {
+ case mode_subshell:
+ TOK_CALL_ERROR(tok, TOK_UNTERMINATED_SUBSHELL, PARAN_ERROR);
+ break;
+ case mode_array_brackets:
+ case mode_array_brackets_and_subshell:
+ TOK_CALL_ERROR(tok, TOK_UNTERMINATED_SUBSHELL, SQUARE_BRACKET_ERROR); // TOK_UNTERMINATED_SUBSHELL is a lie but nobody actually looks at it
+ break;
+ default:
+ assert(0 && "Unexpected mode in read_string");
+ break;
+ }
return;
}