Daniel B. firstname.lastname@example.org writes:
Robert K. wrote:
2006/4/29, Bill G. email@example.com:
I was hoping for a simpler solution, but that’ll work.
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
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.