aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-09-26 22:41:09 +1000
committerGravatar axel <axel@liljencrantz.se>2006-09-26 22:41:09 +1000
commitd0f187073567c1bfaf9a4190951bc1723f3815dc (patch)
tree6678d3ef4b3231f2dc18e7815b4db368d4b9e47c /parser.c
parentb71f5d09b022578484c943bdeec1823a8627ad29 (diff)
Add syntax check to see that the for builtin is not given an insufficient number of arguments
darcs-hash:20060926124109-ac50b-b088397933fa7ea539e48fa9fcd461de8295f7ce.gz
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/parser.c b/parser.c
index 3c9d4c89..c7088ff4 100644
--- a/parser.c
+++ b/parser.c
@@ -3043,6 +3043,8 @@ int parser_test( const wchar_t * buff,
current_tokenizer_pos = tok_get_pos( &tok );
int last_type = tok_last_type( &tok );
+ int end_of_cmd = 0;
+
switch( last_type )
{
case TOK_STRING:
@@ -3512,6 +3514,8 @@ int parser_test( const wchar_t * buff,
had_cmd = 0;
is_pipeline=0;
forbid_pipeline=0;
+ end_of_cmd = 1;
+
break;
}
@@ -3558,6 +3562,8 @@ int parser_test( const wchar_t * buff,
needs_cmd=1;
is_pipeline=1;
had_cmd=0;
+ end_of_cmd = 1;
+
}
break;
}
@@ -3590,6 +3596,7 @@ int parser_test( const wchar_t * buff,
}
had_cmd = 0;
+ end_of_cmd = 1;
break;
}
@@ -3610,6 +3617,35 @@ int parser_test( const wchar_t * buff,
}
break;
}
+
+ if( end_of_cmd )
+ {
+ if( cmd && wcscmp( cmd, L"for" ) == 0 )
+ {
+ if( arg_count >= 0 && arg_count < 2 )
+ {
+ /*
+ Not enough arguments to the for builtin
+ */
+ err = 1;
+
+ if( out )
+ {
+ error( SYNTAX_ERROR,
+ tok_get_pos( &tok ),
+ BUILTIN_FOR_ERR_COUNT,
+ L"for",
+ arg_count );
+
+ print_errors( out, prefix );
+ }
+ }
+
+ }
+
+ }
+
+
}
if( needs_cmd )