I have a script that takes a MySQL SELECT query as its sole argument. Typically I enclose that query in single quotes and use double quotes within the query for enclosing the strings that are arguments of the query itself.
Occasionally this presents a problem, usually when the query itself must search for quote characters (single or double). I'm sure this can be resolved by properly escaping the single and double-quotes, but this is tricky since MySQL and the Linux shell may use different methods for escaping.
Example... here's an example, and it seems incredibly difficult to me... it needs to find single-quote characters that are preceded by a backslash. Note, this example does not intend to escape any characters for either MySQL or the CLI. The percent symbols act as wildcards in MySQL.
./show-results 'SELECT * FROM `table` WHERE `column` LIKE "%\'%"'
Is it possible to use something other than single or double-quotes to enclose a shell argument?
$'whatever'with some designated escapes. Not sure how convenient that might be for the average user. It might be simpler to use a Here Document instead of a command arg, as this will be treated as data without expansions.echo $'don\'t do it'. But here documents avoid the leaning toothpick syndrome../show-resultsis invoked?