Substituting the value of variable inside backtick operator
ruby
Solution
In Ruby, unlike Perl, the dollar sign indicates a global variable, not a plain regular variable to expand in a string. In a string, you need to use the #{} construct:
p `ruby -e "p #{script_dir}"`
An example:
irb(main):011:0> str = '\'howdy\''
=> "'howdy'"
irb(main):012:0> `ruby -e "p #{str}"`
=> "\"howdy\"\n"
Problem
How can I substitute the value of a variable inside the backtick operator? ``` script_dir = File.expand_path File.dirname(__FILE__) p `ruby -e p "$script_dir"` # this does not work ```