function drush_confirm

8.0.x drush_confirm($msg, $indent = 0)
6.x drush_confirm($msg, $indent = 0)
7.x drush_confirm($msg, $indent = 0)
3.x drush_confirm($msg, $indent = 0)
5.x drush_confirm($msg, $indent = 0)
master drush_confirm($msg, $indent = 0)

Asks the user a basic yes/no question.


string $msg: The question to ask.

int $indent: The number of spaces to indent the message.

Return value

bool TRUE if the user enters "y" or FALSE if "n".

Related topics

29 calls to drush_confirm()
drush_config_import in commands/core/
Command callback. Import from specified config directory (defaults to sync).
drush_config_set in commands/core/
Config set command callback.
drush_core_pre_site_install in commands/core/
Perform setup tasks for installation.
drush_core_rsync in commands/core/
A command callback.
drush_core_watchdog_delete in commands/core/
Command callback.

... See full list


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


function drush_confirm($msg, $indent = 0) {
  drush_print_prompt((string) $msg . " (y/n): ", $indent);

  // Automatically accept confirmations if the --yes argument was supplied.
  if (drush_get_context('DRUSH_AFFIRMATIVE')) {
    return TRUE;
  // Automatically cancel confirmations if the --no argument was supplied.
  elseif (drush_get_context('DRUSH_NEGATIVE')) {
    return FALSE;
  // See before changing this.
  $stdin = fopen("php://stdin", "r");

  while ($line = fgets($stdin)) {
    $line = trim($line);
    if ($line == 'y') {
      return TRUE;
    if ($line == 'n') {
      return FALSE;
    drush_print_prompt((string) $msg . " (y/n): ", $indent);