exec the cd command in a ruby script

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

    Stumbled across this while searching to do the same thing.

    I was able to solve this by running multiple statements within the backticks.

    'cd #{path} &&  && cd ..'
    

提交回复
热议问题