Browse Source

The completion of the fix for Bug #975: include proper handling of parsing

chunks of data returned by the external environment listing program
(whose command is returned by getProcEnvCommand()).  UNIX environment
variables can contain text with embedded newlines.

Submitted by; Daniel Rall <dlr@finemaltcoding.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268942 13f79535-47bb-0310-9956-ffa450edef68
master
Nico Seessle 24 years ago
parent
commit
4ee2e5c268
1 changed files with 21 additions and 2 deletions
  1. +21
    -2
      src/main/org/apache/tools/ant/taskdefs/Execute.java

+ 21
- 2
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -163,10 +163,29 @@ public class Execute {

BufferedReader in =
new BufferedReader(new StringReader(out.toString()));
String line;
String var = null;
String line, lineSep = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
procEnvironment.addElement(line);
if (line.indexOf('=') == -1) {
// Chunk part of previous env var (UNIX env vars can
// contain embedded new lines).
if (var == null) {
var = lineSep + line;
}
else {
var += lineSep + line;
}
}
else {
// New env var...append the previous one if we have it.
if (var != null) {
procEnvironment.addElement(var);
}
var = line;
}
}
// Since we "look ahead" before adding, there's one last env var.
procEnvironment.addElement(var);
}
catch (java.io.IOException exc) {
exc.printStackTrace();


Loading…
Cancel
Save