-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed reading from file when using standard separator (" ") #222
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ | |
import java.util.Map; | ||
import java.util.ResourceBundle; | ||
|
||
import bsh.classpath.BshClassPath.GeneratedClassSource; | ||
|
||
import com.beust.jcommander.FuzzyMap.IKey; | ||
import com.beust.jcommander.converters.IParameterSplitter; | ||
import com.beust.jcommander.converters.NoConverter; | ||
|
@@ -351,11 +353,28 @@ private String[] expandArgs(String[] originalArgv) { | |
// Expand @ | ||
// | ||
for (String arg : originalArgv) { | ||
|
||
if (arg.startsWith("@")) { | ||
String fileName = arg.substring(1); | ||
vResult1.addAll(readFile(fileName)); | ||
} | ||
List<String> fileArgs = readFile(fileName); | ||
List<String> splitFileArgs = Lists.newArrayList(); | ||
//special treatment for standard separator (" ") | ||
String[] v1 = fileArgs.toArray(new String[0]); | ||
for (int i = 0; i < fileArgs.size(); i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please correct indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why introducing |
||
String arg2 = fileArgs.get(i); | ||
if (isOption(v1, arg2)) { | ||
String sep = getSeparatorFor(v1, arg2); | ||
if (" ".equals(sep)) { | ||
String[] sp = arg2.split("[" + sep + "]", 2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why using |
||
for (String ssp : sp) { | ||
splitFileArgs.add(ssp); | ||
} | ||
}else{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please add blanks around |
||
splitFileArgs.add(arg2); | ||
} | ||
} | ||
} | ||
vResult1.addAll(splitFileArgs); | ||
} | ||
else { | ||
List<String> expanded = expandDynamicArg(arg); | ||
vResult1.addAll(expanded); | ||
|
@@ -481,9 +500,9 @@ private static List<String> readFile(String fileName) { | |
|
||
try { | ||
BufferedReader bufRead = new BufferedReader(new FileReader(fileName)); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove whitespace added at the end of the line. |
||
String line; | ||
|
||
// Read through file one line at time. Print line # and line | ||
while ((line = bufRead.readLine()) != null) { | ||
// Allow empty lines and # comments in these at files | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are adding an import but you are not referencing it.