17
17
import java .util .ArrayList ;
18
18
import java .util .List ;
19
19
import java .util .ResourceBundle ;
20
- import java .util .regex .Matcher ;
21
20
import java .util .regex .Pattern ;
22
21
23
22
import static cucumber .runtime .model .CucumberFeature .load ;
26
25
public class RuntimeOptions {
27
26
public static final String VERSION = ResourceBundle .getBundle ("cucumber.version" ).getString ("cucumber-jvm.version" );
28
27
public static final String USAGE = FixJava .readResource ("/cucumber/runtime/USAGE.txt" );
29
- private static final Pattern SHELLWORDS_PATTERN = Pattern .compile ("[^\\ s']+|'([^']*)'" );
30
28
31
29
private final List <String > glue = new ArrayList <String >();
32
30
private final List <Object > filters = new ArrayList <Object >();
@@ -48,7 +46,7 @@ public class RuntimeOptions {
48
46
* @param argv the arguments
49
47
*/
50
48
public RuntimeOptions (String argv ) {
51
- this (new FormatterFactory (), shellWords (argv ));
49
+ this (new FormatterFactory (), Shellwords . parse (argv ));
52
50
}
53
51
54
52
/**
@@ -78,7 +76,7 @@ public RuntimeOptions(Env env, FormatterFactory formatterFactory, List<String> a
78
76
79
77
String cucumberOptionsFromEnv = env .get ("cucumber.options" );
80
78
if (cucumberOptionsFromEnv != null ) {
81
- parse (shellWords (cucumberOptionsFromEnv ));
79
+ parse (Shellwords . parse (cucumberOptionsFromEnv ));
82
80
}
83
81
filters .addAll (lineFilters );
84
82
@@ -88,19 +86,6 @@ public RuntimeOptions(Env env, FormatterFactory formatterFactory, List<String> a
88
86
setFormatterOptions ();
89
87
}
90
88
91
- private static List <String > shellWords (String cmdline ) {
92
- List <String > matchList = new ArrayList <String >();
93
- Matcher shellwordsMatcher = SHELLWORDS_PATTERN .matcher (cmdline );
94
- while (shellwordsMatcher .find ()) {
95
- if (shellwordsMatcher .group (1 ) != null ) {
96
- matchList .add (shellwordsMatcher .group (1 ));
97
- } else {
98
- matchList .add (shellwordsMatcher .group ());
99
- }
100
- }
101
- return matchList ;
102
- }
103
-
104
89
private void parse (List <String > args ) {
105
90
List <Object > parsedFilters = new ArrayList <Object >();
106
91
List <Object > parsedLineFilters = new ArrayList <Object >();
0 commit comments