I am hitting one issue after another with Ruby, single quote and double quotes today.
I have this Ruby oneliner that was used to detect whether a multiline strings exist within a file.
ruby -e 'exit(gets(nil) =~ %r{${line}} ? 0 : 1)' ${file}
It works fine until when my $line contains a single quote such as
ruby -e 'exit(gets(nil) =~ %r{This is David's car\nMazda 3\n} ? 0 : 1)' /tmp/bug8164
-bash: syntax error near unexpected token `)'
I tried to escape the single quote to the following but no luck.
ruby -e 'exit(gets(nil) =~ %r{This is David\'s car\nMazda 3\n} ? 0 : 1)' /tmp/bug8164
-bash: syntax error near unexpected token `)'
Any idea or thought? Thanks