On 4/29/06, Lloyd Zusman <ljz / asfast.com> wrote:
> Daniel Berger <djberg96 / gmail.com> writes:
>
> > Robert Klemme wrote:
> >> 2006/4/29, Bill Guindon <agorilla / gmail.com>:
> >>
> >>> I was hoping for a simpler solution, but that'll work.
> >>> Thanks much.
> >> I don't know why this complex stuff was suggested.  Dir.chdir does the
> >> job - or am I missing something?
> >
> > Dir.chdir doesn't change your directory in the shell it's running in
> > after the program has finished.  That's what he was after I think.
>
> Unfortunately, no program running in any language can change the
> directory in the shell it's running in, after the program has finished
> ... assuming that the program is invoked as a process that is separate
> from that of the shell (which is how ruby is invoked).
>
> The shell maintains its own idea of the current working directory.  When
> a program is invoked, the current working directory can be changed in
> that program's environment, but when the program exits, you are back in
> the shell's environment, with its own idea of the current working
> directory.
>
> If you invoke a .bat or .cmd script, that is run by the winxp command
> shell itself, and those programs can therefore change the shell's idea
> of the current working directory.  But once you invoke a .exe, you are
> in a separate program environment that has no way to change the
> properties of the shell.
>
> This is a function of how the operating system is designed.  It's true
> for windows-based systems as well as unix-like systems.

Thanks for the detailed answer.

That was pretty much my thinking on it, but I was doing some wishful
thinking that there was some clever way to get around it.  The batch
file approach will work, but it's just not as elegant as I'd like. 
Was also wondering if there was some Win32 call that might pull it
off.

> --
>  Lloyd Zusman
>  ljz / asfast.com
>  God bless you.
>
>
>


--
Bill Guindon (aka aGorilla)
The best answer to most questions is "it depends".