From a4880437748b79ef5046ae286caa8d501ffa8ca6 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Tue, 31 Jan 2012 13:25:20 -0700 Subject: [PATCH] Check for mysql after parsing options so --help works even if mysql isn't in PATH. --- bin/pt-stalk | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/pt-stalk b/bin/pt-stalk index e9ce1d43..767b1e87 100755 --- a/bin/pt-stalk +++ b/bin/pt-stalk @@ -1154,15 +1154,6 @@ main() { if [ "${0##*/}" = "$TOOL" ] \ || [ "${0##*/}" = "bash" -a "$_" = "$0" ]; then - # Check that mysql and mysqladmin are in PATH. If not, we're - # already dead in the water, so don't bother with cmd line opts, - # just error and exit. - [ -n "$(mysql --help)" ] \ - || die "Cannot execute mysql. Check that it is in PATH." - [ -n "$(mysqladmin --help)" ] \ - || die "Cannot execute mysqladmin. Check that it is in PATH." - - # Parse command line options. We must do this first so we can # see if --daemonize was specified. mk_tmpdir @@ -1181,6 +1172,14 @@ if [ "${0##*/}" = "$TOOL" ] \ exit 0 fi + # Check that mysql and mysqladmin are in PATH. If not, we're + # already dead in the water, so don't bother with cmd line opts, + # just error and exit. + [ -n "$(mysql --help)" ] \ + || die "Cannot execute mysql. Check that it is in PATH." + [ -n "$(mysqladmin --help)" ] \ + || die "Cannot execute mysqladmin. Check that it is in PATH." + # Now that we have the cmd line opts, check that we can actually # connect to MySQL. [ -n "$(mysql $EXT_ARGV -e 'SELECT 1')" ] \