I'd like to change the pwd of the current shell from within a ruby script. So:
> pwd
/tmp
> ruby cdscript.rb
> pwd
/usr/bin
This is the code I have right now:
exec('cd /usr/bin')
Unfortunately, cd is a builtin command. So:
`exec': No such file or directory - cd (Errno:ENOENT)
Any workaround for this?
No way to get it working in ruby itself, so I switched gears. I modified the script to output the target directory path and then defined a function in .bashrc that would pass the arguments through the script and then cd to the right directory. Not self-contained as I would have hoped, but it did the job.
Thanks for the replies, folks.