- Reading all the lines into an array is a big error.
- It's a bit unintiuitive because you don't really know what strings to escape on the bash command line. In the example, some are escaped and others aren't.
- In the end I think this could be achieved with a simple bash function:
$ rb() { ruby -lane "print \$_.instance_eval(\"$@\")"; }
$ echo hello | rb capitalize
$ Hello