ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r485295 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java
Date Sun, 10 Dec 2006 22:54:09 GMT
Author: peterreilly
Date: Sun Dec 10 14:54:07 2006
New Revision: 485295

URL: http://svn.apache.org/viewvc?view=rev&rev=485295
Log:
retain the original casiness when handing replaceing case insensitive env properties

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java?view=diff&rev=485295&r1=485294&r2=485295
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java Sun Dec 10 14:54:07
2006
@@ -625,24 +625,32 @@
         }
         Vector osEnv = (Vector) getProcEnvironment().clone();
         for (int i = 0; i < env.length; i++) {
+            String keyValue = env[i];
             // Get key including "="
-            String key = env[i].substring(0, env[i].indexOf('=') + 1);
+            String key = keyValue.substring(0, keyValue.indexOf('=') + 1);
             if (environmentCaseInSensitive) {
                 // Nb: using default locale as key is a env name
                 key = key.toLowerCase();
             }
             int size = osEnv.size();
+            // Find the key in the current enviroment copy
+            // and remove it.
             for (int j = 0; j < size; j++) {
                 String osEnvItem = (String) osEnv.elementAt(j);
-                if (environmentCaseInSensitive) {
-                    osEnvItem = osEnvItem.toLowerCase();
-                }
-                if (osEnvItem.startsWith(key)) {
+                String convertedItem = environmentCaseInSensitive
+                    ? osEnvItem.toLowerCase() : osEnvItem;
+                if (convertedItem.startsWith(key)) {
                     osEnv.removeElementAt(j);
+                    if (environmentCaseInSensitive) {
+                        // Use the original casiness of the key
+                        keyValue = osEnvItem.substring(0, key.length())
+                            + keyValue.substring(key.length());
+                    }
                     break;
                 }
             }
-            osEnv.addElement(env[i]);
+            // Add the key to the enviromnent copy
+            osEnv.addElement(keyValue);
         }
         return (String[]) (osEnv.toArray(new String[osEnv.size()]));
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message