From: Sami Samhuri Date: 2007-06-22T03:04:35+09:00 Subject: Re: How can I implement cd (change dir) command in Ruby? On 6/21/07, Sam Kong wrote: > Hi, > > This question is rather out of curiosity than practical. > > Let's say I want to make a script which is equivalent to cd command in > Linux. > Is it possible? Only if your shell is done in Ruby as well. chdir(2) changes the directory for the process which invokes it. cd is a shell built-in, one which has no analog in /bin. > system("cd #{ARGV[0]}") didn't work. That will spawn a new process running /bin/sh. That shell will change its directory and then exit. afaik what you want is not possible without resorting to (ugly) trickery. Hope this helps. -- Sami Samhuri