File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -57,3 +57,7 @@ _colcon_comp () {
5757} && complete -F _colcon_comp colcon
5858
5959complete -u groups w
60+
61+ command_not_found_handle() {
62+ /usr/lib/command-not-found -- "$1"
63+ }
Original file line number Diff line number Diff line change 33
44pub mod parser;
55
6- use crate :: ShellCore ;
6+ use crate :: { Feeder , Script , ShellCore } ;
77use crate :: utils:: exit;
88use super :: { Command , Pipe , Redirect } ;
99use crate :: core:: data:: Value ;
@@ -98,7 +98,17 @@ impl SimpleCommand {
9898 match unistd:: execvp ( & cargs[ 0 ] , & cargs) {
9999 Err ( Errno :: E2BIG ) => exit:: arg_list_too_long ( & self . args [ 0 ] , core) ,
100100 Err ( Errno :: EACCES ) => exit:: permission_denied ( & self . args [ 0 ] , core) ,
101- Err ( Errno :: ENOENT ) => exit:: not_found ( & self . args [ 0 ] , core) ,
101+ Err ( Errno :: ENOENT ) => {
102+ if core. data . functions . contains_key ( "command_not_found_handle" ) {
103+ let s = "command_not_found_handle " . to_owned ( ) + & self . args [ 0 ] . clone ( ) ;
104+ let mut f = Feeder :: new ( & s) ;
105+ match Script :: parse ( & mut f, core, false ) {
106+ Some ( mut script) => script. exec ( core) ,
107+ _ => { } ,
108+ }
109+ }
110+ exit:: not_found ( & self . args [ 0 ] , core)
111+ } ,
102112 Err ( err) => {
103113 eprintln ! ( "Failed to execute. {:?}" , err) ;
104114 process:: exit ( 127 )
You can’t perform that action at this time.
0 commit comments