diff --git a/commands/simpletest/simpletest.drush.inc b/commands/simpletest/simpletest.drush.inc
index 807533f..3254b93 100644
--- a/commands/simpletest/simpletest.drush.inc
+++ b/commands/simpletest/simpletest.drush.inc
@@ -44,6 +44,11 @@ function simpletest_drush_command() {
     'drupal dependencies' => array('simpletest'),
     'core' => array('6','7'),
   );
+  $items['test drush'] = array(
+    'callback' => 'drush_test_drush',
+    'description' => 'Run drush-specific tests',
+    'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
+  );
   return $items;
 }
 
@@ -61,10 +66,9 @@ function drush_test_mail($recipients) {
     return drush_set_error('DRUSH_SIMPLETEST_RUNTESTS_SH', dt('You must copy or symlink run-tests.sh into your /scripts directory beneath Drupal root.'));
   }
   
-  $php = drush_find_php();
   $extra = drush_get_option('extra');
   $url = escapeshellarg(url('', array('absolute' => TRUE)));
-  $exec = $php . " $run_tests --php '" . $php . '\' --url ' . $url . " $extra";
+  $exec = "$run_tests --php '" . DRUSH_COMMAND . '\' --url ' . $url . " $extra";
   drush_shell_exec($exec);
   $output =  implode("\n", drush_shell_exec_output());
   $subject = 'Simpletest results - ' . drush_simpletest_format_results($output);
@@ -87,3 +91,17 @@ function drush_simpletest_format_results($output) {
     return dt('Unknown.');
   }
 }
+
+/**
+ * Simple drush self-test procedure
+ *
+ * This only tests self-execution for now.
+ *
+ * XXX: this needs to be adapted to a testing framework, see:
+ *
+ * http://drupal.org/node/483940
+ */
+function drush_test_drush() {
+  drush_log(dt("Invoking %drush help in a subprocess", array('%drush' => DRUSH_COMMAND)));
+  drush_backend_invoke('help', array(), 'GET', FALSE);
+}
\ No newline at end of file
diff --git a/drush b/drush
index fa5b274..aeef37b 100755
--- a/drush
+++ b/drush
@@ -39,11 +39,11 @@ elif [ -f /Applications/xampp/xamppfiles/bin/php ]; then # XAMPP on OS X
   /Applications/xampp/xamppfiles/bin/php $SCRIPT_PATH "$@"
 else
   # We check for a command line (cli) version of php, and if found use that.
-  /usr/bin/env php-cli -v &> /dev/null
+  which php-cli >/dev/null 2>&1
   if [ "$?" = 0 ] ; then
-    /usr/bin/env php-cli $SCRIPT_PATH "$@"
+    php-cli $SCRIPT_PATH "$@"
   else
     # Alternatively we run with straight php, which works on most other systems.
-    /usr/bin/env php $SCRIPT_PATH "$@"
+    php $SCRIPT_PATH "$@"
   fi
 fi
diff --git a/drush.php b/drush.php
index 7b2aacb..bf7d24e 100755
--- a/drush.php
+++ b/drush.php
@@ -1,3 +1,4 @@
+#!/usr/bin/env php
 <?php
 // $Id: drush.php,v 1.73 2009/10/26 02:26:36 weitzman Exp $
 
@@ -20,7 +21,8 @@ if (version_compare(phpversion(), DRUSH_MINIMUM_PHP) < 0) {
 }
 
 define('DRUSH_BASE_PATH', dirname(__FILE__));
-define('DRUSH_COMMAND', $GLOBALS['argv'][0]);
+
+
 define('DRUSH_REQUEST_TIME', microtime(TRUE));
 
 require_once DRUSH_BASE_PATH . '/includes/environment.inc';
diff --git a/includes/backend.inc b/includes/backend.inc
index 1fea487..9f0b8b9 100644
--- a/includes/backend.inc
+++ b/includes/backend.inc
@@ -326,8 +326,7 @@ function _drush_backend_generate_command($command, &$data, $method = 'GET', $dru
     $command .= ' ' . escapeshellarg($arg);
   }
   // @TODO: Implement proper multi platform / multi server support.
-  $php  = drush_find_php();
-  $cmd = $php . sprintf(escapeshellcmd(" %s %s %s --backend"), escapeshellcmd($drush_path), $option_str, $command);
+  $cmd = sprintf(escapeshellcmd(" %s %s %s --backend"), escapeshellcmd($drush_path), $option_str, $command);
 
   if (!is_null($hostname)) {
     $username = (!is_null($username)) ? $username : get_current_user();
diff --git a/includes/environment.inc b/includes/environment.inc
index eac00da..9613ed0 100644
--- a/includes/environment.inc
+++ b/includes/environment.inc
@@ -112,6 +112,11 @@ define('DRUSH_TABLE_VERSION', '1.1.3');
 define('DRUSH_TABLE_URL', 'http://cvs.php.net/viewvc.cgi/pear/Console_Table/Table.php?revision=1.28&view=co');
 
 /**
+ * 
+ */
+define('DRUSH_COMMAND', drush_find_drush());
+
+/**
  * Helper function listing phases.
  *
  * For commands that need to iterate through the phases, such as help
@@ -846,24 +851,66 @@ function drush_valid_db_credentials() {
   }
 }
 
-// Copied from run-tests.sh
-function drush_find_php() {
-  // Determine location of php command automatically, unless a command line argument is supplied.
-  if (!$php = drush_get_option('php')) {
-    if (!empty($_ENV['_'])) {
-      // '_' is an environment variable set by the shell. It contains the command that was executed.
-      $php = $_ENV['_'];
-    }
-    elseif (!empty($_ENV['SUDO_COMMAND'])) {
-      // 'SUDO_COMMAND' is an environment variable set by the sudo program.
-      // Extract only the PHP interpreter, not the rest of the command.
-      list($php, ) = explode(' ', $_ENV['SUDO_COMMAND'], 2);
-    }
-    else {
-      drush_set_error('DRUSH_PHP_PATH_NOT_FOUND', dt('Unable to automatically determine the path to the PHP interpreter. Please supply the --php argument.'));
-    }
+/**
+ * Determine a proper way to call drush again
+ *
+ * This check if we were called directly or as an argument to some
+ * wrapper command (php and sudo are checked now).
+ *
+ * Calling ./drush.php directly yields the following environment:
+ *
+ * _SERVER["argv"][0] => ./drush.php
+ * _SERVER["_"] => /home/anarcat/dist/drush/./drush.php
+ * 
+ * Calling php ./drush.php yields the following:
+ * 
+ * _SERVER["argv"][0] => drush.php
+ * _SERVER["_"] => /usr/bin/php
+ *
+ * Calling env php drush.php yields the following:
+ *
+ * _SERVER["argv"][0] => drush.php
+ * _SERVER["_"] => /usr/bin/env
+ *
+ * The latter is a problem as there is no way to find the PHP
+ * executable then. We consider it's the job of the shell script
+ * wrapper to do that fiddling around and we will therefore assume
+ * that $argv[0] is a proper PHP binary.
+ *
+ * Calling sudo php drush.php yields the following:
+ *
+ * _SERVER["argv"][0] => drush.php
+ * _SERVER["SUDO_COMMAND"] => /usr/bin/php drush.php [arguments]
+ *
+ * Notice how _ is missing when running in sudo.
+ *
+ * Therefore, we assume that if $_ finishes with $argv[0], we can call
+ * it directly again. Otherwise, we assume that $_ is the php binary
+ * and $argv[0] is the path to drush.php. We will use __FILE__,
+ * however, since we do not want to rely on (potentially) relative
+ * paths.
+ *
+ * The DRUSH_COMMAND constant is initialised to the value of this
+ * function when environment.inc is loaded.
+ *
+ * @see DRUSH_COMMAND
+ */
+function drush_find_drush() {
+  if (!empty($_ENV['SUDO_COMMAND']) && empty($_SERVER['_'])) {
+    // 'SUDO_COMMAND' is an environment variable set by the sudo program.
+    // Extract only the PHP interpreter, not the rest of the command.
+    list($_SERVER['_'], ) = explode(' ', $_ENV['SUDO_COMMAND'], 2);
+  }
+  if (substr($_SERVER['_'], -strlen($_SERVER['argv'][0])) == $_SERVER['argv'][0]) {
+    // $GLOBALS['_'] and $GLOBALS['argv'][0] both finish with the same,
+    // which means we were called directly
+    $drush = realpath($_SERVER['_']);
+  } else {
+    // not called directly, we were called as an argument to PHP, which
+    // should be in $GLOBALS['_']
+    $drush = $_SERVER['_'] . ' ' . realpath($_SERVER['argv'][0]);
   }
-  return $php;
+  return $drush;
 }
 
 /**
