function drush_op

8.0.x drush.inc drush_op($callable)
6.x drush.inc drush_op($function)
7.x drush.inc drush_op($callable)
3.x drush.inc drush_op($function)
4.x drush.inc drush_op($function)
5.x drush.inc drush_op($function)
master drush.inc 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.

Parameters

$function: 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

Related topics

24 calls to drush_op()
drush_archive_dump in commands/core/archive.drush.inc
Command callback. Generate site archive file.
drush_cache_clear in commands/core/cache.drush.inc
Command callback for drush cache-clear.
drush_copy_dir in includes/drush.inc
Copy $src to $dest.
drush_core_pre_site_install in commands/core/site_install.drush.inc
Perform setup tasks for installation.
drush_core_search_index in commands/core/search.drush.inc

... See full list

File

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

Code

function drush_op($function) {
  $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');
  }

  // Special checking for drush_op('system')
  if ($function == 'system') {
    drush_log(dt("Do not call drush_op('system'); use drush_op_system instead"), 'debug');
  }

  if (drush_get_context('DRUSH_VERBOSE') || drush_get_context('DRUSH_SIMULATE')) {
    drush_log(sprintf("Calling %s(%s)", $function, implode(", ", $args_printed)), 'debug');
  }

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

  return call_user_func_array($function, $args);
}