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

12 calls to drush_shell_cd_and_exec()
DrushMakeProject::applyPatches in commands/make/
Retrieve and apply any patches specified by the makefile to this project.
DrushMakeProject::processGitInfoFiles in commands/make/
Process info files when downloading things from git.
drush_archive_dump in commands/core/
Command callback. Generate site archive file.
drush_config_export in commands/core/
Command callback: Export config to specified directory (usually sync).
drush_pm_git_drupalorg_compute_rebuild_version in commands/pm/package_handler/
Helper function to compute the rebulid version string for a project.

... See full list

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


includes/, line 56
Functions for executing system commands. (e.g. exec(), system(), ...).


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;