function drush_op

8.0.x drush_op($callable)
6.x drush_op($function)
7.x drush_op($callable)
3.x drush_op($function)
4.x drush_op($function)
5.x drush_op($function)
master drush_op($callable)

Calls a given function, passing through all arguments unchanged.

This should be used when calling possibly mutative or destructive functions (e.g. unlink() and other file system functions) so that can be suppressed if the simulation mode is enabled.

Important: Call or shell output.


$callable: The name of the function. Any additional arguments are passed along.

Return value

The return value of the function, or TRUE if simulation mode is enabled.

See also

drush_op_system() to execute a shell command,

drush_shell_exec() to execute a shell command and capture the

35 calls to drush_op()
DrushMakeProject::applyPatches in commands/make/
Retrieve and apply any patches specified by the makefile to this project.
drush_archive_dump in commands/core/
Command callback. Generate site archive file.
drush_archive_restore in commands/core/
Command callback. Restore web site(s) from a site archive file.
drush_cache_command_clear in commands/core/
Command callback for drush cache-clear.
drush_cache_command_get in commands/core/
Print an object returned from the cache.

... See full list


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


function drush_op($callable) {
  $args_printed = array();
  $args = func_get_args();
  array_shift($args); // Skip function name
  foreach ($args as $arg) {
    $args_printed[] = is_scalar($arg) ? $arg : (is_array($arg) ? 'Array' : 'Object');

  if (!is_array($callable)) {
    $callable_string = $callable;
  else {
    if (is_object($callable[0])) {
      $callable_string = get_class($callable[0]) . '::' . $callable[1];
    else {
      $callable_string = implode('::', $callable);

  // Special checking for drush_op('system')
  if ($callable == 'system') {
    drush_log(dt("Do not call drush_op('system'); use drush_op_system instead"), LogLevel::DEBUG);

  if (drush_get_context('DRUSH_VERBOSE') || drush_get_context('DRUSH_SIMULATE')) {
    drush_log(sprintf("Calling %s(%s)", $callable_string, implode(", ", $args_printed)), LogLevel::DEBUG);

  if (drush_get_context('DRUSH_SIMULATE')) {
    return TRUE;

  return drush_call_user_func_array($callable, $args);