D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Simple Script Problem

 

On 1/19/07, Jamie Andrews <jamie@xxxxxxxxxxxx> wrote:>
> Removing the #!/bin/sh ( the bang line ) does not stop this fundamental
> mode of operation
>

No but this will :- consider this script called test.bash

echo "Current dir is `pwd`"
cd /
echo "Current dir is `pwd`"

so if we run

robin@thefatcontroller:~$ pwd
/home/robin
robin@thefatcontroller:~$ ./test.bash
Current dir is /home/robin
Current dir is /
robin@thefatcontroller:~$ pwd
/home/robin
robin@thefatcontroller:~$ . test.bash
Current dir is /home/robin
Current dir is /
robin@thefatcontroller:/$ pwd
/



the . operator in bash will run a script in the current environment
not a copy. Not to be confused with the current directory . !



-- 
Robin Cornelius
http://www.byteme.org.uk

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html