diff --git a/src/Symfony/Component/Console/Helper/Helper.php b/src/Symfony/Component/Console/Helper/Helper.php index 8bf82a148732a..b9727d13b4aea 100644 --- a/src/Symfony/Component/Console/Helper/Helper.php +++ b/src/Symfony/Component/Console/Helper/Helper.php @@ -22,6 +22,11 @@ abstract class Helper implements HelperInterface { protected $helperSet = null; + const OS_UNKNOWN = 1; + const OS_WIN = 2; + const OS_LINUX = 3; + const OS_OSX = 4; + /** * {@inheritdoc} */ @@ -121,4 +126,20 @@ public static function removeDecoration(OutputFormatterInterface $formatter, $st return $string; } + + /** + * GET Os Terminal to define CLI's behavior + * Used especially for autocompletion. + * + * @return string + */ + public function getOSTerminal() + { + switch (true) { + case stristr(PHP_OS, 'DAR'): return self::OS_OSX; + case stristr(PHP_OS, 'WIN'): return self::OS_WIN; + case stristr(PHP_OS, 'LINUX'): return self::OS_LINUX; + default: return self::OS_UNKNOWN; + } + } } diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 1f3e4ff14ac38..ba3e55f2cd9d0 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -114,7 +114,7 @@ public function doAsk(OutputInterface $output, Question $question) $inputStream = $this->inputStream ?: STDIN; $autocomplete = $question->getAutocompleterValues(); - if (null === $autocomplete || !$this->hasSttyAvailable()) { + if ((null === $autocomplete || self::OS_WIN == $this->getOSTerminal()) || !$this->hasSttyAvailable()) { $ret = false; if ($question->isHidden()) { try {