ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Execute.java
Date Sat, 14 Apr 2001 07:25:17 GMT
nico        01/04/14 00:25:16

  Modified:    src/main/org/apache/tools/ant/taskdefs Execute.java
  Log:
  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>
  
  Revision  Changes    Path
  1.16      +21 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java
  
  Index: Execute.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Execute.java	2001/04/11 22:44:19	1.15
  +++ Execute.java	2001/04/14 07:25:14	1.16
  @@ -163,10 +163,29 @@
   
               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();
  
  
  

Mime
View raw message