Index: commands/pm/package_handler/wget.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/pm/package_handler/wget.inc,v
retrieving revision 1.5
diff -u -p -r1.5 wget.inc
--- commands/pm/package_handler/wget.inc	2 Jun 2009 03:45:44 -0000	1.5
+++ commands/pm/package_handler/wget.inc	21 Nov 2009 03:18:53 -0000
@@ -20,6 +20,10 @@ function package_handler_install_project
   $filename = array_pop($filename);
   $fullpath = $path . $filename;
 
+  // Set our directory to the download location.
+  $olddir = getcwd();
+  chdir($path);
+
   // Download it.
   if (!drush_shell_exec("wget " . $info['download_link'])) {
     drush_shell_exec("curl -O " . $info['download_link']);
@@ -29,12 +33,14 @@ function package_handler_install_project
     drush_log("Downloading " . $filename . " was successful.");
   }
   else {
+    chdir($olddir);
     return drush_set_error('DRUSH_PM_DOWNLOAD_FAILED', "Unable to download $filename to $path from ". $info['download_link']);
   }
 
   // Check Md5 hash
   if (md5_file($filename) != $info['mdhash'] && !drush_get_context('DRUSH_SIMULATE')) {
     drush_op('unlink', $filename);
+    chdir($olddir);
     return drush_set_error('DRUSH_PM_FILE_CORRUPT', "File $filename is corrupt (wrong md5 checksum).");
   }
   else {
@@ -44,12 +50,16 @@ function package_handler_install_project
   // Decompress
   drush_shell_exec("gzip -d " . $filename);
   $tarpath = substr($filename, 0, strlen($filename)-3);
+
   // Untar
-  drush_shell_exec("tar -xf $tarpath -C \"$path\"");
+  drush_shell_exec("tar -xf $tarpath");
   // We're not using tar -xzf because that's not working on windows...
 
   // Remove the tarball
   drush_op('unlink', $tarpath);
+  
+  // Set working directory back to the previous working directory.
+  chdir($olddir);
 
   // 'drupal' project gets tarred as drupal-6-10/foo instead of drupal/foo so must be excluded from test below.
   // Translations get untarred into the Drupal root, so there is no easy way to check.
