exec the cd command in a ruby script

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

    You can't change the working directory (or the environment variables for that matter) of the shell that invoked you in a ruby script (or any other kind of application). The only commands that can change the pwd of the current shell are shell built-ins.

提交回复
热议问题