Browse files

Changed to my own old SED commands because the sqlhost sed was greedy…

… and variable fetch would go to the last quote.

That meant for the line:
define('DB_HOST', 'localhost');   // 99% chance you won't need to change this value

it would produce an $sqlhost value of:
localhost');   // 99% chance you won
  • Loading branch information...
1 parent b8e5a01 commit 9b7565a6131eb201d49977fb0ba8a46b9e707ad9 @brianlayman committed Mar 2, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 wpsql
8 wpsql
@@ -1,7 +1,7 @@
-sqlname=`sed -n "s/.*\(['\"]\)DB_NAME\1\s*,\s*\(['\"]\)\(.*\)\2.*/\3/p" $1`
-sqluser=`sed -n "s/.*\(['\"]\)DB_USER\1\s*,\s*\(['\"]\)\(.*\)\2.*/\3/p" $1`
-sqlhost=`sed -n "s/.*\(['\"]\)DB_HOST\1\s*,\s*\(['\"]\)\(.*\)\2.*/\3/p" $1`
-sqlpass=`sed -n "s/.*\(['\"]\)DB_PASSWORD\1\s*,\s*\(['\"]\)\(.*\)\2.*/\3/p" $1`
+sqlname=$(sed -n "/define('DB_NAME', '/s/.*, '\([^']*\).*/\1/p" $1)
+sqluser=$(sed -n "/define('DB_USER', '/s/.*, '\([^']*\).*/\1/p" $1)
+sqlpass=$(sed -n "/define('DB_PASSWORD', '/s/.*, '\([^']*\).*/\1/p" $1)
+sqlhost=$(sed -n "/define('DB_HOST', '/s/.*, '\([^']*\).*/\1/p" $1)
mysql -h $sqlhost -u $sqluser -p$sqlpass $sqlname

0 comments on commit 9b7565a

Please sign in to comment.