diff options
author | axel <axel@liljencrantz.se> | 2008-02-05 09:09:05 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2008-02-05 09:09:05 +1000 |
commit | d7396ac59f44c061698ef00aa7a0592ffb2e9988 (patch) | |
tree | 491b7d9b2a15fd57dc6c9521bee106579d68be30 /highlight.c | |
parent | 3f439e9cd309ad20e6b0b45c6921a7a7a17db41b (diff) |
Fix bug causing flood of error messages in terminal when trying to highlight an invalid command, reported by Denilson F. de Sa.
darcs-hash:20080204230905-ac50b-0829b69835347e5875656ae735181b724f10de2a.gz
Diffstat (limited to 'highlight.c')
-rw-r--r-- | highlight.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/highlight.c b/highlight.c index 21644daf..625d8e50 100644 --- a/highlight.c +++ b/highlight.c @@ -530,6 +530,20 @@ static void highlight_param( const wchar_t * buff, } } +static int has_expand_reserved( wchar_t *str ) +{ + while( *str ) + { + if( *str >= EXPAND_RESERVED && + *str <= EXPAND_RESERVED_END ) + { + return 1; + } + str++; + } + return 0; +} + void highlight_shell( wchar_t * buff, int *color, @@ -636,10 +650,10 @@ void highlight_shell( wchar_t * buff, Command. First check that the command actually exists. */ cmd = expand_one( context, - wcsdup(tok_last( &tok )), - EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES); + wcsdup(tok_last( &tok )), + EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES); - if( cmd == 0 ) + if( (cmd == 0) || has_expand_reserved( cmd ) ) { color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR; } @@ -698,7 +712,7 @@ void highlight_shell( wchar_t * buff, } tok_set_pos( &tok, mark ); } - + if( !is_subcommand ) { wchar_t *tmp; |