function drush_print_file

8.0.x output.inc drush_print_file($file)
6.x output.inc drush_print_file($file)
7.x output.inc drush_print_file($file)
4.x drush.inc drush_print_file($file)
5.x output.inc drush_print_file($file)
master output.inc drush_print_file($file)

Print the contents of a file.

Parameters

string $file: Full path to a file.

Related topics

2 calls to drush_print_file()
drush_docs_errorcodes in commands/core/docs.drush.inc
docs-error-codes command. Print a list of all error codes that can be found.
_drush_pm_releasenotes in commands/pm/pm.drush.inc
Internal function: prints release notes for given drupal projects.
2 string references to 'drush_print_file'
docs_drush_command in commands/core/docs.drush.inc
Implementation of hook_drush_command().
sandwich_drush_command in examples/sandwich.drush.inc
Implementation of hook_drush_command().

File

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

Code

function drush_print_file($file) {
  // Don't even bother to print the file in --no mode
  if (drush_get_context('DRUSH_NEGATIVE')) {
    return;
  }
  if ((substr($file, -4) == ".htm") || (substr($file, -5) == ".html")) {
    $tmp_file = drush_tempnam(basename($file));
    file_put_contents($tmp_file, drush_html_to_text(file_get_contents($file)));
    $file = $tmp_file;
  }
  // Do not wait for user input in --yes or --pipe modes
  if (drush_get_context('DRUSH_PIPE')) {
    drush_print_pipe(file_get_contents($file));
  }
  elseif (drush_get_context('DRUSH_AFFIRMATIVE')) {
    drush_print(file_get_contents($file));
  }
  elseif (drush_shell_exec_interactive("less %s", $file)) {
    return;
  }
  elseif (drush_shell_exec_interactive("more %s", $file)) {
    return;
  }
  else {
    drush_print(file_get_contents($file));
  }
}