[plug] bash bodgy

Craig Dyke grail at westnet.com.au
Sat Jun 5 19:41:55 WST 2004


For those of you gurus out there, don't be too harsh when you see perhaps
how easy this question is.

Anyhow, I started to copy a bash script given to me.
What the script ultimately does is not important, but, there is a line 
that says:

cd ${home}

Now being new to scipting I looked up why I wasn't in the 'home' 
directory when script completed
as this is the last line. I discovered that because scipt creates its 
own shell and then leaves it when
script completes that I am returned to directory from where I executed 
the script.

I WANT to be in 'home' when script completes.
After googling I found info to say that if I put either of the following:

source cd ${home}

OR

. cd ${home}

that this would do what I require.

Unfortunately that doesn't seem to be happening.
When I run the script I get the following message:

./tt: line 5: cd: No such file or directory

Can anyone explain this to me?

Script looks like:

#!/bin/bash

home=/usr/src

. cd ${home}





More information about the plug mailing list