function drush_shell_cd_and_exec

8.0.x drush_shell_cd_and_exec($effective_wd, $cmd)
6.x drush_shell_cd_and_exec($effective_wd, $cmd)
7.x drush_shell_cd_and_exec($effective_wd, $cmd)
4.x drush_shell_cd_and_exec($effective_wd, $cmd)
5.x drush_shell_cd_and_exec($effective_wd, $cmd)
master drush_shell_cd_and_exec($effective_wd, $cmd)

Executes a shell command at a new working directory. The old cwd is restored on exit.


$effective_wd: The new working directory to execute the shell command at.

$cmd: The command to execute. May include placeholders used for sprintf.

...: Values for the placeholders specified in $cmd. Each of these will be passed through escapeshellarg() to ensure they are safe to use on the command line.

Return value

TRUE on success, FALSE on failure

Related topics

6 calls to drush_shell_cd_and_exec()
drush_archive_dump in commands/core/
Command callback. Generate site archive file.
drush_pm_cvs in commands/pm/package_handler/
General CVS helper function.
drush_tarball_extract in includes/
Extract a tarball.
package_handler_download_project in commands/pm/package_handler/
Download a project.
package_handler_post_download in commands/pm/package_handler/
Post download action.

... See full list

2 string references to 'drush_shell_cd_and_exec'
drush_pm_version_control_bzr::pre_update in commands/pm/version_control/
Implementation of pre_update().
drush_pm_version_control_svn::pre_update in commands/pm/version_control/
Implementation of pre_update().


includes/, line 1262
The drush API implementation and helpers.


function drush_shell_cd_and_exec($effective_wd, $cmd) {
  $args = func_get_args();

  $effective_wd = array_shift($args);
  $cwd = getcwd();
  drush_op('chdir', $effective_wd);
  $result = call_user_func_array('drush_shell_exec', $args);
  drush_op('chdir', $cwd);
  return $result;