You are here

private function QuestionHelper::getShell in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Helper/QuestionHelper.php \Symfony\Component\Console\Helper\QuestionHelper::getShell()

Returns a valid unix shell.

Return value

string|bool The valid shell name, false in case no valid shell is found

1 call to QuestionHelper::getShell()
QuestionHelper::getHiddenResponse in vendor/symfony/console/Helper/QuestionHelper.php
Gets a hidden response from user.

File

vendor/symfony/console/Helper/QuestionHelper.php, line 409

Class

QuestionHelper
The QuestionHelper class provides helpers to interact with the user.

Namespace

Symfony\Component\Console\Helper

Code

private function getShell() {
  if (null !== self::$shell) {
    return self::$shell;
  }
  self::$shell = false;
  if (file_exists('/usr/bin/env')) {

    // handle other OSs with bash/zsh/ksh/csh if available to hide the answer
    $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
    foreach (array(
      'bash',
      'zsh',
      'ksh',
      'csh',
    ) as $sh) {
      if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
        self::$shell = $sh;
        break;
      }
    }
  }
  return self::$shell;
}