Status
Blaok

If you are working with some software which requires you to source some code and messes up with your PATH and other environment variables like Vivado and Merlin compiler, here is a simple and straightforward method to get rid of the mess (to some extent).

#!/bin/bash
VERSION=2016.1
. /space/Xilinx/SDAccel/${VERSION}/settings64.sh
# do something if necessary
if ! test "$0" -ef "$(which $(basename $0))"
then
    exec $(basename $0) "$@"
else
    if test -t 2
    then
        echo "Recursive call detected!" 1&>2
    fi
fi

Some notes:

  • Start with #!/bin/bash if you or your script use bash-specific syntax!
  • Give this file execution permission with chmod +x!
  • Make sure this file itself has the same name as the target program, or is soft-linked to it!
  • Use . instead of source, which improves compatibility!