File tree 1 file changed +7
-4
lines changed
src/mhashim6/commander/main
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ public class CommandBuilder {
15
15
private final ArrayList <String > cmdArgs , cmdOptions , finalCommand ;
16
16
17
17
// private static final String WHITE_SPACE = " ";
18
- private static final String COMMA = "," ;
19
18
private static final String EMPTY_STRING = "" ;
20
19
private static final Pattern QUOTES_PATTERN = Pattern .compile ("([^\" |^']\\ S*|[\" |'].+?[\" |'])\\ s*" );
21
20
// ============================================================
@@ -107,9 +106,13 @@ private String finalCmdLine(ArrayList<String> cmdList){
107
106
private static String [] splitCmd (String cmd ) {
108
107
List <String > strings = new ArrayList <>();
109
108
Matcher m = QUOTES_PATTERN .matcher (cmd );
110
- while (m .find ())
111
- strings .add (m .group (1 ));
112
- return strings .toArray (new String [strings .size ()]);
109
+ while (m .find ()) {
110
+ String token = m .group (1 );
111
+ token = token .startsWith ("'" ) || token .startsWith ("\" " ) ?
112
+ token .replace ("'" , EMPTY_STRING ).replace ("\" " , EMPTY_STRING ) : token ;
113
+ strings .add (token );
114
+ }
115
+ return strings .toArray (new String [0 ]);
113
116
}
114
117
115
118
private void clearAll () {
You can’t perform that action at this time.
0 commit comments