I've installed some of my code that needs Perl 5.010 on a CentOS 5.x server using perlbrew and it needs the two lines
source ~/perl5/perlbrew/etc/bashrc
and
perlbrew switch perl-5.10.1
To be executed in the shell before I have perl 5.010 in my /usr/bin/env, so I tried to create the following executable bash script to minimise these two steps to ./setEnv.sh
#!/bin/bash
echo "**setting environment variables - 'perlbrew switch-off' to exit"
SETSOURCE= `source ~/perl5/perlbrew/etc/bashrc`
echo $SETSOURCE
SETPERL= `perlbrew switch perl-5.10.1`
echo $SETPERL
Use the
source
command without backticks. Just write a linein your script. (
source
has side-effects, which doesn't work when you are in a sub-shell. I'm not even sure you can runsource
as an external command.)