@@ -11,28 +11,39 @@ pub struct Substitution {
1111    pub  text :  String , 
1212    pub  key :  String , 
1313    pub  value :  Value , 
14+     pub  append :  bool , 
1415} 
1516
1617impl  Substitution  { 
1718    pub  fn  eval ( & mut  self ,  core :  & mut  ShellCore )  -> Value  { 
18-         match  & self . value  { 
19+         match  self . value . clone ( )  { 
1920            Value :: None       => Value :: EvaluatedSingle ( "" . to_string ( ) ) , 
20-             Value :: Single ( v)  => Self :: eval_as_value ( & v,  core) , 
21-             Value :: Array ( a)   => Self :: eval_as_array ( & mut  a. clone ( ) ,  core) , 
21+             Value :: Single ( v)  => self . eval_as_value ( & v,  core) , 
22+             Value :: Array ( a)   => self . eval_as_array ( & mut  a. clone ( ) ,  core) , 
2223            _                => Value :: None , 
2324        } 
2425    } 
2526
26-     fn  eval_as_value ( w :  & Word ,  core :  & mut  ShellCore )  -> Value  { 
27+     fn  eval_as_value ( & self ,  w :  & Word ,  core :  & mut  ShellCore )  -> Value  { 
28+         let  prev = match  self . append  { 
29+             true   => core. data . get_param ( & self . key ) , 
30+             false  => "" . to_string ( ) , 
31+         } ; 
32+ 
2733        match  w. eval_as_value ( core)  { 
28-             Some ( s)  => Value :: EvaluatedSingle ( s) , 
34+             Some ( s)  => Value :: EvaluatedSingle ( prev +  & s) , 
2935            None     => Value :: None , 
3036        } 
3137    } 
3238
33-     fn  eval_as_array ( a :  & mut  Array ,  core :  & mut  ShellCore )  -> Value  { 
39+     fn  eval_as_array ( & self ,  a :  & mut  Array ,  core :  & mut  ShellCore )  -> Value  { 
40+         let  prev = match  self . append  { 
41+             true   => core. data . get_array_all ( & self . key ) , 
42+             false  => vec ! [ ] , 
43+         } ; 
44+ 
3445        match  a. eval ( core)  { 
35-             Some ( values)  => Value :: EvaluatedArray ( values) , 
46+             Some ( values)  => Value :: EvaluatedArray ( [ prev ,   values] . concat ( ) ) , 
3647            None          => Value :: None , 
3748        } 
3849    } 
@@ -42,6 +53,7 @@ impl Substitution {
4253            text :  String :: new ( ) , 
4354            key :  String :: new ( ) , 
4455            value :  Value :: None , 
56+             append :  false , 
4557        } 
4658    } 
4759
@@ -55,7 +67,13 @@ impl Substitution {
5567
5668        let  mut  name_eq = feeder. consume ( len) ; 
5769        ans. text  += & name_eq; 
70+ 
5871        name_eq. pop ( ) ; 
72+         if  name_eq. ends_with ( "+" )  { 
73+             ans. append  = true ; 
74+             name_eq. pop ( ) ; 
75+         } 
76+ 
5977        ans. key  = name_eq. clone ( ) ; 
6078
6179        if  let  Some ( a)  = Array :: parse ( feeder,  core)  { 
0 commit comments