From 85e77b14f7a0c2c0e8ada500421b7a1bcf6f1836 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Thu, 7 Aug 2014 09:02:32 +0200 Subject: [PATCH] add way to test command under windows --- src/Symfony/Component/Finder/Shell/Shell.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Finder/Shell/Shell.php b/src/Symfony/Component/Finder/Shell/Shell.php index f65f16d372..7c57e7b7f9 100644 --- a/src/Symfony/Component/Finder/Shell/Shell.php +++ b/src/Symfony/Component/Finder/Shell/Shell.php @@ -50,19 +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) + $testCommand = 'command -v '; + if (self::TYPE_WINDOWS === $this->type) { + $testCommand = 'where '; + } + $command = escapeshellcmd($command); - // todo: find a better way (command could not be available) - exec('command -v '.$command, $output, $code); + exec($testCommand . $command, $output, $code); return 0 === $code && count($output) > 0; }