@@ -44,8 +44,8 @@ impl SimpleCommand {
44
44
ans. command_name = w. text . clone ( ) ;
45
45
}
46
46
47
- if ans. words . is_empty ( ) {
48
- if Self :: set_alias ( & w, & mut ans . words , & mut ans . text , core, feeder) ? {
47
+ if ans. words . is_empty ( ) || ans . continue_alias_check {
48
+ if ans . set_alias ( & w, core, feeder) ? {
49
49
return Ok ( true ) ;
50
50
}
51
51
}
@@ -56,26 +56,29 @@ impl SimpleCommand {
56
56
Ok ( true )
57
57
}
58
58
59
- fn set_alias ( word : & Word , words : & mut Vec < Word > , text : & mut String ,
59
+ fn set_alias ( & mut self , word : & Word ,
60
60
core : & mut ShellCore , feeder : & mut Feeder ) -> Result < bool , ParseError > {
61
+ self . continue_alias_check = false ;
61
62
let mut w = word. text . clone ( ) ;
62
63
if ! core. replace_alias ( & mut w) {
63
64
return Ok ( false ) ;
64
65
}
65
66
67
+ self . continue_alias_check = w. ends_with ( " " ) ;
68
+
66
69
let mut feeder_local = Feeder :: new ( & mut w) ;
67
70
loop {
68
71
match Word :: parse ( & mut feeder_local, core, None ) {
69
72
Ok ( Some ( w) ) => {
70
- text. push_str ( & w. text ) ;
71
- words. push ( w) ;
73
+ self . text . push_str ( & w. text ) ;
74
+ self . words . push ( w) ;
72
75
} ,
73
76
_ => break ,
74
77
}
75
- command:: eat_blank_with_comment ( & mut feeder_local, core, text) ;
78
+ command:: eat_blank_with_comment ( & mut feeder_local, core, & mut self . text ) ;
76
79
}
77
80
78
- if words. is_empty ( ) {
81
+ if self . words . is_empty ( ) {
79
82
return Err ( ParseError :: WrongAlias ( w) ) ;
80
83
}
81
84
0 commit comments