I have several projects that require me to change versions of Java/Grails/Maven. I'm trying to handle this with some scripts that would make the changes. For example:
#!/bin/sh
export JAVA_HOME=/cygdrive/c/dev/Java/jdk1.5.0_22
export PATH=$JAVA_HOME/bin:$PATH
export GRAILS_HOME=/cygdrive/c/dev/grails-1.0.3
export PATH=$GRAILS_HOME/bin:$PATH
export MAVEN_HOME=/cygdrive/c/dev/apache-maven-2.0.11
export PATH=$MAVEN_HOME/bin:$PATH
which java
which grails
which mvn
When this executes, it successfully changes the PATH within the context of the script, but then the script ends, and no change has been accomplished.
How can I run a script in a way to change the PATH in for the shell in which I am currently working?
I'm using Cygwin.
source
works only forbash
. Output forksh
:/bin/ksh: source: not found
, forsh
:sh: 0: source: not found
. The answer below should be considered for these shells. – Danny Lo Apr 08 '15 at 09:19bash
centric. – andcoz Apr 08 '15 at 13:29