exec the cd command in a ruby script

前端 未结 6 386
情深已故
情深已故 2021-01-13 21:52

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

6条回答
  •  执念已碎
    2021-01-13 22:41

    You can try to use system instead of exec. It works for me.

    Like system("cd #{new_path} && && cd #{original_path}")

提交回复
热议问题