Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit 860c9b9

Browse files
committed
Improved the detection of the executed command thanks to the path dirs
1 parent b6e7a69 commit 860c9b9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Symfony/Installer/AboutCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
9292
*/
9393
private function getExecutedCommand()
9494
{
95+
$pathDirs = explode(':', $_SERVER['PATH']);
9596
$executedCommand = $_SERVER['PHP_SELF'];
96-
$executedCommand = preg_replace('~/usr/local/bin/~', '', $executedCommand);
97+
$executedCommandDir = dirname($executedCommand);
98+
99+
if (in_array($executedCommandDir, $pathDirs)) {
100+
$executedCommand = str_replace($executedCommandDir, '', $executedCommand);
101+
$executedCommand = trim($executedCommand, DIRECTORY_SEPARATOR);
102+
}
97103

98104
return $executedCommand;
99105
}

src/Symfony/Installer/NewCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,14 @@ private function getExecutedCommand()
562562
$version = $this->version;
563563
}
564564

565+
$pathDirs = explode(':', $_SERVER['PATH']);
565566
$executedCommand = $_SERVER['PHP_SELF'];
566-
$executedCommand = preg_replace('~/usr/local/bin/~', '', $executedCommand);
567+
$executedCommandDir = dirname($executedCommand);
568+
569+
if (in_array($executedCommandDir, $pathDirs)) {
570+
$executedCommand = str_replace($executedCommandDir, '', $executedCommand);
571+
$executedCommand = trim($executedCommand, DIRECTORY_SEPARATOR);
572+
}
567573

568574
return sprintf('%s new %s %s', $executedCommand, $this->projectName, $version);
569575
}

0 commit comments

Comments
 (0)