Subject: Re: More Bourne shell script help
To: Andy Ruhl <acruhl@gmail.com>
From: Johnny Billquist <bqt@update.uu.se>
List: netbsd-help
Date: 07/27/2006 09:34:00
Andy Ruhl wrote:
> On 7/26/06, Johnny Billquist <bqt@update.uu.se> wrote:
> 
>> The current path, as well as all environment variables are only
>> inherited by cild processes. You can never affect the parent process.
> 
> Yeah, I should have stated that I understand this, I was just trying
> to write it with as much clarity as possible and as the newbie I am.
> 
> Currently I know of only 2 ways to accomplish this:
> 
> 1. Set these as functions in the shell, then run them.
> 2. Fork a new shell and have it run the cd command to the new
> directory, although I haven't had luck with that yet (probably haven't
> read the man pages well enough so far).

If you understood what I wrote above, then you should understand that #2 
here is impossible.

And #1 is very strangely formulated.
The only thing you actually can do is perform the wanted directory 
change in the shell. That's it.
You can either do it interactively, as in typing "cd ...", or you can 
write it in a file, and make your current shell run through the commands 
in that file, as in typing ". <file>".

> On the advice of another kind individual, I've already implemented the
> entire thing into the shell as a function with the . <functions>
> method. It works fine.

. <function> is the wrong concept. ". <filename>" means that the shell 
will temporarily read input from that file instead from the keyboard, 
and perform each line the same way as if you had typed it in.
A file is not a function. :-)

> Would be nice to have it work as a standalone script though, even if
> it must fork a new shell.

If it forks a new shell, then only that shell's concept of working 
directory is changed, not yours.

	Johnny

-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt@update.uu.se           ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol