ShivanKaul
ShivanKaul

Reputation: 757

Defining bash aliases from Ruby script

I'm trying to set a Bash alias from a Ruby script. The intended functionality would be (from the Ruby script):

However, using the system command doesn't work because it launches a new subshell.

Any advice?

Upvotes: 0

Views: 438

Answers (1)

Mircea
Mircea

Reputation: 10566

what you want to do is not doable.
the script you are launching cannot really alter the environment of the shell.
one way to do this would be to source the output of the ruby script and to have the script just generate the commands. This way you are instructing the shell to actually do the right thing.

something like

source $(my_ruby_script.rb)

have the script alter the aliases and at the end read and print out the file.

Upvotes: 1

Related Questions