function drush_shell_cd_and_exec

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

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

Parameters

$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/archive.drush.inc
Command callback. Generate site archive file.
drush_pm_cvs in commands/pm/package_handler/cvs.inc
General CVS helper function.
drush_tarball_extract in includes/drush.inc
Extract a tarball.
package_handler_download_project in commands/pm/package_handler/git_drupalorg.inc
Download a project.
package_handler_post_download in commands/pm/package_handler/git_drupalorg.inc
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/bzr.inc
Implementation of pre_update().
drush_pm_version_control_svn::pre_update in commands/pm/version_control/svn.inc
Implementation of pre_update().

File

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

Code

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;
}