exec the cd command in a ruby script

前端 未结 6 434
情深已故
情深已故 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:34

    You won't be able to change the working directory of your shell.

    When it executes ruby, it forks so you get a new environment, with a new working directory.

提交回复
热议问题