In my ~/.bashrc, I have a function:
function sayHi() {
echo "hi, $@"
}
and in Ruby I want to:
`sayHi "friend"`
however, sayHi is “not found” in whatever context ruby runs exec or system.
How could I get Ruby to use functions in my .bashrc?
Your
.bashrcis only run for interactive shells. When you execute a command using backquotes in Ruby, it does not execute the command in an interactive shell.You can force an interactive shell by running
bash -i. For example, to run your command under an interactive shell, use: