File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -329,10 +329,11 @@ impl Cmd {
329
329
330
330
let arg_str = arg. to_string_lossy ( ) . to_string ( ) ;
331
331
if arg_str != IGNORE_CMD && !self . args . iter ( ) . any ( |cmd| * cmd != IGNORE_CMD ) {
332
- let v: Vec < & str > = arg_str. split ( '=' ) . collect ( ) ;
333
- if v. len ( ) == 2 && v[ 0 ] . chars ( ) . all ( |c| c. is_ascii_alphanumeric ( ) || c == '_' ) {
334
- self . vars . insert ( v[ 0 ] . into ( ) , v[ 1 ] . into ( ) ) ;
335
- return self ;
332
+ if let Some ( ( key, value) ) = arg_str. split_once ( '=' ) {
333
+ if key. chars ( ) . all ( |c| c. is_ascii_alphanumeric ( ) || c == '_' ) {
334
+ self . vars . insert ( key. into ( ) , value. into ( ) ) ;
335
+ return self ;
336
+ }
336
337
}
337
338
self . in_cmd_map = CMD_MAP . lock ( ) . unwrap ( ) . contains_key ( arg) ;
338
339
}
Original file line number Diff line number Diff line change @@ -263,3 +263,8 @@ fn test_empty_arg() {
263
263
let opt = "" ;
264
264
assert ! ( run_cmd!( ls $opt) . is_ok( ) ) ;
265
265
}
266
+
267
+ #[ test]
268
+ fn test_env_var_with_equal_sign ( ) {
269
+ assert ! ( run_cmd!( A ="-c B=c" echo) . is_ok( ) ) ;
270
+ }
You can’t perform that action at this time.
0 commit comments