Say I have a bunch of text in a variable some_varthat can be almost anything.
some_var = "Hello, I'm a \"fancy\" variable | with a pipe, double- and single-quotes (terminated and unterminated), and more."
Also say that in a Ruby CLI application, I want to allow the user to pass this text to any Unix command. I let them enter something like some_var | espeak -a 200 -v en-uswhere the command to the right of the channel is any CLI Unix tool installed on their system.
Let's also say that I have already taken care to separate the choice of variables and the pipe from their input, so I know that I know for 100% exactly which command is after the pipe. (In this case, I want to pass the contents of the variable to espeak -a 200 -v en-us.)
How should I do it? I donβt think I can use the backtick method or literal %x[]. I tried to do the following ...
system("echo '#{some_var}' | espeak -a 200 -v en-us")
... but any special characters click on things and I cannot delete special characters. What should I do?
source
share