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

12 calls to drush_shell_cd_and_exec()
DrushMakeProject::applyPatches in commands/make/make.project.inc
Retrieve and apply any patches specified by the makefile to this project.
DrushMakeProject::processGitInfoFiles in commands/make/make.project.inc
Process info files when downloading things from git.
drush_archive_dump in commands/core/archive.drush.inc
Command callback. Generate site archive file.
drush_config_export in commands/core/config.drush.inc
Command callback: Export config to specified directory (usually sync).
drush_pm_git_drupalorg_compute_rebuild_version in commands/pm/package_handler/git_drupalorg.inc
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/bzr.inc
Implementation of pre_update().
drush_version_control_svn::pre_update in commands/pm/version_control/svn.inc
Implementation of pre_update().

File

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

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