@@ -43,46 +43,43 @@ pub fn run_substitution_builtin(
43
43
com : & mut SimpleCommand ,
44
44
core : & mut ShellCore ,
45
45
) -> Result < bool , ExecError > {
46
- if com. args . is_empty ( ) {
47
- eprintln ! ( "ShellCore::run_builtin" ) ;
48
- return Ok ( false ) ;
49
- }
50
-
51
46
if !core. subst_builtins . contains_key ( & com. args [ 0 ] ) {
52
47
return Ok ( false ) ;
53
48
}
54
49
55
- let func = core . subst_builtins [ & com. args [ 0 ] ] ;
50
+ let mut args = vec ! [ com. args[ 0 ] . clone ( ) ] ;
56
51
let mut subs = vec ! [ ] ;
57
52
for sub in com. substitutions_as_args . iter_mut ( ) {
58
53
match sub {
59
54
SubsArgType :: Subs ( s) => subs. push ( ( * * s) . clone ( ) ) ,
60
55
SubsArgType :: Other ( w) => {
61
56
for arg in w. eval ( core) ? {
62
57
if arg. starts_with ( "-" ) || arg. starts_with ( "+" ) {
63
- com. args . push ( arg) ;
64
- } else {
65
- let mut f = Feeder :: new ( & arg) ;
66
- match Substitution :: parse ( & mut f, core, true , false ) ? {
67
- Some ( mut s) => {
68
- s. quoted = true ;
69
- subs. push ( s) ;
70
- }
71
- _ => {
72
- let mut s = Substitution :: default ( ) ;
73
- s. text = arg;
74
- s. left_hand . text = s. text . clone ( ) ;
75
- s. left_hand . name = s. text . clone ( ) ;
76
- s. quoted = true ;
77
- subs. push ( s) ;
78
- }
58
+ args. push ( arg) ;
59
+ continue ;
60
+ }
61
+
62
+ let mut f = Feeder :: new ( & arg) ;
63
+ match Substitution :: parse ( & mut f, core, true , false ) ? {
64
+ Some ( mut s) => {
65
+ s. quoted = true ;
66
+ subs. push ( s) ;
67
+ }
68
+ _ => {
69
+ let mut s = Substitution :: default ( ) ;
70
+ s. text = arg;
71
+ s. left_hand . text = s. text . clone ( ) ;
72
+ s. left_hand . name = s. text . clone ( ) ;
73
+ s. quoted = true ;
74
+ subs. push ( s) ;
79
75
}
80
76
}
81
77
}
82
78
}
83
79
}
84
80
}
85
81
86
- core. db . exit_status = func ( core, & com. args [ ..] , & mut subs[ ..] ) ;
82
+ let func = core. subst_builtins [ & com. args [ 0 ] ] ;
83
+ core. db . exit_status = func ( core, & args[ ..] , & mut subs[ ..] ) ;
87
84
Ok ( true )
88
85
}
0 commit comments