diff --git a/commands/core/archive.drush.inc b/commands/core/archive.drush.inc index a7cb4e8..ecf914d 100644 --- a/commands/core/archive.drush.inc +++ b/commands/core/archive.drush.inc @@ -170,6 +170,12 @@ function drush_archive_dump($sites_subdirs = '@self') { $docroot = basename($docroot_path); $workdir = dirname($docroot_path); $dereference = (drush_get_option('preserve-symlinks', FALSE)) ? '' : '--dereference '; + // Convert destination path to Unix style for tar on MinGW - see http://drupal.org/node/1844224 + if (drush_is_mingw()) { + $destination_orig = $destination; + $destination = str_replace('\\', '/', $destination); + $destination = preg_replace('$^([a-zA-Z]):$', '/$1', $destination); + } // Archive Drupal core, excluding sites dir. drush_shell_cd_and_exec($workdir, "$tar {$tar_extra_options} --exclude \"{$docroot}/sites\" {$dereference}-cf %s %s", $destination, $docroot); // Add sites/all to the same archive. @@ -257,6 +263,11 @@ function drush_archive_dump($sites_subdirs = '@self') { drush_shell_cd_and_exec($workdir, "$tar --dereference -vrf %s %s", $destination, $docroot . '/sites/default/default.settings.php'); } + // Switch back to original destination in case it was modified for tar on MinGW. + if (!empty($destination_orig)) { + $destination = $destination_orig; + } + // Compress the archive drush_shell_exec("gzip --no-name -f %s", $destination); diff --git a/drush b/drush index 323fc6f..0e86d14 100755 --- a/drush +++ b/drush @@ -11,6 +11,14 @@ SELF_DIRNAME="`dirname -- "$0"`" SELF_PATH="`cd -P -- "$SELF_DIRNAME" && pwd -P`/`basename -- "$0"`" +# Decide if we are running a Unix shell on Windows +case "`uname -a`" in + CYGWIN*) + CYGWIN=1 ;; + MINGW*) + MINGW=1 ;; +esac + # Resolve symlinks - this is the equivalent of "readlink -f", but also works with non-standard OS X readlink. while [ -h "$SELF_PATH" ]; do # 1) cd to directory of the symlink @@ -25,10 +33,9 @@ done # Build the path to drush.php. SCRIPT_PATH="`dirname "$SELF_PATH"`/drush.php" -case "`uname -a`" in - CYGWIN*) - SCRIPT_PATH="`cygpath -w -a -- "$SCRIPT_PATH"`" ;; -esac +if [ ! -z "$CYGWIN" ] ; then + SCRIPT_PATH="`cygpath -w -a -- "$SCRIPT_PATH"`" +fi # If not exported, try to determine and export the number of columns. # We do not want to run `tput cols` if $TERM is empty or "dumb", because @@ -37,7 +44,8 @@ esac # error message is suppressed, but tput cols becomes confused about the # terminal and prints out the default value (80). if [ -z $COLUMNS ] && [ -n "$TERM" ] && [ "$TERM" != dumb ] && [ ! -z "`which tput`" ] ; then - # Note to cygwin users: install the ncurses package to get tput command. + # Note to cygwin/mingw/msys users: install the ncurses package to get tput command. + # Note to mingw/msys users: there is no precompiled ncurses package. if COLUMNS="`tput cols`"; then export COLUMNS fi @@ -58,8 +66,7 @@ else fi # On MSYSGIT, we need to use "php", not the full path to php - # See http://drupal.org/node/1659014 for an explanation of the comparison op. - if [ ! -z "$MSYSTEM" ] && [ "x${MSYSTEM}" != "x${MSYSTEM#MINGW}" ] ; then + if [ ! -z "$MINGW" ] ; then php="php" fi fi @@ -67,6 +74,13 @@ fi # Check to see if the user has provided a php.ini file or drush.ini file in any conf dir # Last found wins, so search in reverse priority order for conf_dir in "`dirname "$SELF_PATH"`" /etc/drush $HOME/.drush ; do + if [ ! -d $conf_dir ] ; then + continue + fi + # Handle paths that don't start with a drive letter on MinGW shell. Equivalent to cygpath on Cygwin. + if [ ! -z "$MINGW" ] ; then + conf_dir=`sh -c "cd $conf_dir; pwd -W"` + fi if [ -f "$conf_dir/php.ini" ] ; then drush_php_ini=$conf_dir/php.ini fi diff --git a/includes/drush.inc b/includes/drush.inc index 13535f6..9ae2fc1 100644 --- a/includes/drush.inc +++ b/includes/drush.inc @@ -926,7 +926,7 @@ function drush_download_file($url, $destination = FALSE, $cache_duration = 0) { function _drush_download_file($url, $destination, $overwrite = TRUE) { static $use_wget; if ($use_wget === NULL) { - $use_wget = drush_shell_exec('which wget'); + $use_wget = drush_shell_exec('wget --version'); } $destination_tmp = drush_tempnam('download_file'); diff --git a/includes/environment.inc b/includes/environment.inc index 4f2ae73..52e9504 100644 --- a/includes/environment.inc +++ b/includes/environment.inc @@ -644,14 +644,16 @@ function drush_is_mingw($os = NULL) { * Return tar executable name specific for the current OS */ function drush_get_tar_executable() { - return drush_is_windows() ? "bsdtar.exe" : "tar"; + return drush_is_windows() ? (drush_is_mingw() ? "tar.exe" : "bsdtar.exe") : "tar"; } /** * Checks if the operating system has bash. + * + * MinGW has bash, but PHP isn't part of MinGW and hence doesn't run in bash. */ function drush_has_bash($os = NULL) { - return drush_is_cygwin($os) || !drush_is_windows($os); + return (drush_is_cygwin($os) && !drush_is_mingw($os)) || !drush_is_windows($os); } /*