A bash puzzle
Richard Esplin
richard-lists at esplins.org
Mon May 7 13:06:06 MDT 2012
I've been asked to help with some Drupal development. To make it tolerable, I drive everything in code so that I can apply some lifecycle management principles. Being Drupal, this regularly requires editing the database directly.
I have a bash script which drives Drush to make changes. The important part of the script looks like this:
function run_drush_cmd {
$DRUSH_BIN --root=${DRUPAL_ROOT} --uri=${SITE_URI} $@
}
run_drush_cmd "sql-query \"delete from ldap_servers where sid='ldap1';\""
This produces an error about messed up quoting in my SQL syntax:
"ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"delete' at line 1"
It works if instead of calling the function I put together the entire Drush command on a single line of my script:
$DRUSH_BIN --root=${DRUPAL_ROOT} --uri=${SITE_URI} sql-query "delete from ldap_servers where sid='ldap1';"
I have tried a lot of different styles of quoting, but I can't figure out how to tell the function to pass the string to the external binary correctly. I am obviously not understanding something.
Any thoughts on what bash is doing?
Richard
More information about the PLUG
mailing list