Ant exec shell script - loses environment Ant exec shell script - loses environment shell shell

Ant exec shell script - loses environment


Have you exported the variable? Sub-processes will not see the variable unless you export it:

$ cat a.xml<project>  <exec executable="bash" newenvironment="false" dir=".">    <arg value="script.sh"/>  </exec></project>$ cat script.sh#!/bin/shenv$ MY_VARIABLE=defined$ ant -f a.xml | grep MY_VARIABLE$ export MY_VARIABLE$ ant -f a.xml | grep MY_VARIABLE     [exec] MY_VARIABLE=defined


Uhm, that executes a new bash shell (with whatever config and new environment are defined for your active user) and then the bash shell takes the arguments and executes.

Might try the following to execute in the current shell environment

<exec executable="script.sh" newenvironment="false" dir="./"></exec>