mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Add support for the Ubuntu 'command-no-found' handler, which suggests a package to install in order to get a command.
darcs-hash:20080114223124-75c98-ab1658d54086394cf13f3a6210543c0b790362c4.gz
This commit is contained in:
parent
a2660cfb76
commit
537ab32dd9
11
event.c
11
event.c
|
@ -704,9 +704,11 @@ void event_free( event_t *e )
|
|||
}
|
||||
|
||||
|
||||
void event_fire_generic(const wchar_t *name)
|
||||
void event_fire_generic_internal(const wchar_t *name, ...)
|
||||
{
|
||||
event_t ev;
|
||||
va_list va;
|
||||
wchar_t *arg;
|
||||
|
||||
CHECK( name, );
|
||||
|
||||
|
@ -715,6 +717,13 @@ void event_fire_generic(const wchar_t *name)
|
|||
ev.function_name=0;
|
||||
|
||||
al_init( &ev.arguments );
|
||||
va_start( va, name );
|
||||
while( (arg=va_arg(va, wchar_t *) )!= 0 )
|
||||
{
|
||||
al_push( &ev.arguments, arg );
|
||||
}
|
||||
va_end( va );
|
||||
|
||||
event_fire( &ev );
|
||||
}
|
||||
|
||||
|
|
3
event.h
3
event.h
|
@ -164,7 +164,8 @@ const wchar_t *event_get_desc( event_t *e );
|
|||
/**
|
||||
Fire a generic event with the specified name
|
||||
*/
|
||||
void event_fire_generic(const wchar_t *name);
|
||||
#define event_fire_generic( ... ) event_fire_generic_internal( __VA_ARGS__, (void *)0 )
|
||||
|
||||
void event_fire_generic_internal(const wchar_t *name,...);
|
||||
|
||||
#endif
|
||||
|
|
1
parser.c
1
parser.c
|
@ -2086,6 +2086,7 @@ static int parse_job( process_t *p,
|
|||
current_tokenizer_pos=tmp;
|
||||
|
||||
job_set_flag( j, JOB_SKIP, 1 );
|
||||
event_fire_generic(L"fish_command_not_found", (wchar_t *)al_get( args, 0 ) );
|
||||
proc_set_last_status( err==ENOENT?STATUS_UNKNOWN_COMMAND:STATUS_NOT_EXECUTABLE );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,5 +209,11 @@ function __fish_config_interactive -d "Initializations that should be performed
|
|||
commandline -f repaint
|
||||
end
|
||||
|
||||
if test -f /usr/lib/command-not-found $argv
|
||||
function fish_command_not_found_handler --on-event fish_command_not_found
|
||||
/usr/lib/command-not-found $argv
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user