You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2003/04/02 16:53:23 UTC

cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Execute.java

bodewig     2003/04/02 06:53:23

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs Execute.java
  Log:
  Don't hardcode /usr/bin/env for Unix.
  
  PR: 17642
  
  Revision  Changes    Path
  1.385     +4 -1      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.384
  retrieving revision 1.385
  diff -u -r1.384 -r1.385
  --- WHATSNEW	2 Apr 2003 12:00:27 -0000	1.384
  +++ WHATSNEW	2 Apr 2003 14:53:20 -0000	1.385
  @@ -79,6 +79,9 @@
   * <antlr> will now recompile your grammar if the supergrammar has
     changed.  Bugzilla Report 12691.
   
  +* <property env> will now work on Unices with /bin/env instead of
  +  /usr/bin/env.  Bugzilla Report 17642.
  +
   Other changes:
   --------------
   * Shipped XML parser is now Xerces 2.4.0
  @@ -145,7 +148,7 @@
   * <tarfileset> has a new dirmode attribute to specify the permissions
     for directories.
   
  -* <fixcrlf>'s eol attribute now also understand "mac", "unix" and "dos".
  +* <fixcrlf>'s eol attribute now also understands "mac", "unix" and "dos".
   
   * <classfileset> now picks up dependencies of the form MyClass.class. This
     works for the code generated by the Sun java compiler. It may not work for
  
  
  
  1.53      +16 -12    ant/src/main/org/apache/tools/ant/taskdefs/Execute.java
  
  Index: Execute.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- Execute.java	14 Mar 2003 16:01:03 -0000	1.52
  +++ Execute.java	2 Apr 2003 14:53:22 -0000	1.53
  @@ -229,19 +229,23 @@
                   String[] cmd = {"command.com", "/c", "set" };
                   return cmd;
               }
  -        } else if (Os.isFamily("z/os")) {
  -            String[] cmd = {"/bin/env"};
  -            return cmd;
  -        } else if (Os.isFamily("tandem")) {
  -//            String[] cmd = {"/bin/sh -c env"};
  -            String[] cmd = {"/bin/env"};
  -            return cmd;
  -        } else if (Os.isFamily("unix")) {
  -            // Generic UNIX
  -            // Alternatively one could use: /bin/sh -c env
  -            String[] cmd = {"/usr/bin/env"};
  +        } else if (Os.isFamily("z/os") || Os.isFamily("tandem") 
  +                   || Os.isFamily("unix")) {
  +            // On most systems one could use: /bin/sh -c env
  +
  +            // Some systems have /bin/env, others /usr/bin/env, just try
  +            String[] cmd = new String[1];
  +            if (new File("/bin/env").canRead()) {
  +                cmd[0] = "/bin/env";
  +            } else if (new File("/usr/bin/env").canRead()) {
  +                cmd[0] = "/usr/bin/env";
  +            } else {
  +                // rely on PATH
  +                cmd[0] = "env";
  +            }
               return cmd;
           } else if (Os.isFamily("netware") || Os.isFamily("os/400")) {
  +            // rely on PATH
               String[] cmd = {"env"};
               return cmd;
           } else {