On Wed, Jul 23, 2003 at 11:17:58AM +0100, David selby wrote:
> I have a script to show a certain directory, it would be great if that 
> script could change my pwd to that directory.
> 
> Inside my script is a cd /usr/lo....., however since the script 
> automaticly runs in a subshell, when it ends my directory has not changes.

That's right, you can't do that.

> I have tries
> export PWD=/usr/lo....
> 
> no go...

'export' exports the variable to subprocesses, not parent processes.

> source <scriptname> works but is clumbs

'. <scriptname>' works and is less clumsy (not to mention less
bash-specific). It's probably the best you've got.

The only alternative I can think of is to start a new interactive shell
from inside your script. Of course, the problem with that is that if you
run the script a number of times you then have to exit all of them in
turn when you're finished, and shell history might not work the way you
want it to either.

Cheers,

-- 
Colin Watson                                  [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to