mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-30 16:35:16 +08:00
Highlight invalid directories red for the cd builtin
darcs-hash:20060615010038-ac50b-30ada1c67dcb393390f67cf709e433dafc8801b7.gz
This commit is contained in:
parent
a983798295
commit
358f412abb
16
highlight.c
16
highlight.c
@ -519,6 +519,7 @@ void highlight_shell( wchar_t * buff,
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
void *context;
|
void *context;
|
||||||
|
wchar_t *cmd=0;
|
||||||
|
|
||||||
if( !buff || !color )
|
if( !buff || !color )
|
||||||
{
|
{
|
||||||
@ -545,6 +546,7 @@ void highlight_shell( wchar_t * buff,
|
|||||||
int last_type = tok_last_type( &tok );
|
int last_type = tok_last_type( &tok );
|
||||||
int prev_argc=0;
|
int prev_argc=0;
|
||||||
|
|
||||||
|
|
||||||
switch( last_type )
|
switch( last_type )
|
||||||
{
|
{
|
||||||
case TOK_STRING:
|
case TOK_STRING:
|
||||||
@ -571,6 +573,14 @@ void highlight_shell( wchar_t * buff,
|
|||||||
pos-tok_get_pos( &tok ),
|
pos-tok_get_pos( &tok ),
|
||||||
error );
|
error );
|
||||||
|
|
||||||
|
if( cmd && (wcscmp( cmd, L"cd" ) == 0) )
|
||||||
|
{
|
||||||
|
if( !parser_cdpath_get( context, param ) )
|
||||||
|
{
|
||||||
|
color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -579,9 +589,9 @@ void highlight_shell( wchar_t * buff,
|
|||||||
/*
|
/*
|
||||||
Command. First check that the command actually exists.
|
Command. First check that the command actually exists.
|
||||||
*/
|
*/
|
||||||
wchar_t *cmd = expand_one( context,
|
cmd = expand_one( context,
|
||||||
wcsdup(tok_last( &tok )),
|
wcsdup(tok_last( &tok )),
|
||||||
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES);
|
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES);
|
||||||
|
|
||||||
if( cmd == 0 )
|
if( cmd == 0 )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user