diff --git a/src/Symfony/Component/Finder/Shell/Shell.php b/src/Symfony/Component/Finder/Shell/Shell.php index 8586cbc3e5..d17f2fac35 100644 --- a/src/Symfony/Component/Finder/Shell/Shell.php +++ b/src/Symfony/Component/Finder/Shell/Shell.php @@ -50,17 +50,19 @@ class Shell */ public function testCommand($command) { - if (self::TYPE_WINDOWS === $this->type) { - // todo: find a way to test if Windows command exists - return false; - } - if (!function_exists('exec')) { return false; } // todo: find a better way (command could not be available) - exec('command -v '.$command, $output, $code); + $testCommand = 'which '; + if (self::TYPE_WINDOWS === $this->type) { + $testCommand = 'where '; + } + + $command = escapeshellcmd($command); + + exec($testCommand.$command, $output, $code); return 0 === $code && count($output) > 0; }