From eb1571987b0d11106126ec93460d836c21eff9f1 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Aug 2020 09:28:17 +0200 Subject: v0.10.4 from Fedora --- psysh-bin-autoload.patch | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'psysh-bin-autoload.patch') diff --git a/psysh-bin-autoload.patch b/psysh-bin-autoload.patch index a9e670a..42b544e 100644 --- a/psysh-bin-autoload.patch +++ b/psysh-bin-autoload.patch @@ -1,8 +1,8 @@ diff --git a/bin/psysh b/bin/psysh -index 4fbd223..ef7b940 100755 +index 0829481..2e73ad5 100755 --- a/bin/psysh +++ b/bin/psysh -@@ -10,91 +10,7 @@ +@@ -10,101 +10,7 @@ * file that was distributed with this source code. */ @@ -16,7 +16,7 @@ index 4fbd223..ef7b940 100755 - foreach ($argv as $i => $arg) { - if ($arg === '--cwd') { - if ($i >= count($argv) - 1) { -- echo 'Missing --cwd argument.' . PHP_EOL; +- fwrite(STDERR, 'Missing --cwd argument.' . PHP_EOL); - exit(1); - } - $cwd = $argv[$i + 1]; @@ -39,14 +39,21 @@ index 4fbd223..ef7b940 100755 - $chunks = explode('/', $cwd); - while (!empty($chunks)) { - $path = implode('/', $chunks); +- $prettyPath = $path; +- if (isset($_SERVER['HOME']) && $_SERVER['HOME']) { +- $prettyPath = preg_replace('/^' . preg_quote($_SERVER['HOME'], '/') . '/', '~', $path); +- } - - // Find composer.json - if (is_file($path . '/composer.json')) { - if ($cfg = json_decode(file_get_contents($path . '/composer.json'), true)) { - if (isset($cfg['name']) && $cfg['name'] === 'psy/psysh') { -- // We're inside the psysh project. Let's use the local -- // Composer autoload. +- // We're inside the psysh project. Let's use the local Composer autoload. - if (is_file($path . '/vendor/autoload.php')) { +- if (realpath($path) !== realpath(__DIR__ . '/..')) { +- fwrite(STDERR, 'Using local PsySH version at ' . $prettyPath . PHP_EOL); +- } +- - require $path . '/vendor/autoload.php'; - } - @@ -60,9 +67,12 @@ index 4fbd223..ef7b940 100755 - if ($cfg = json_decode(file_get_contents($path . '/composer.lock'), true)) { - foreach (array_merge($cfg['packages'], $cfg['packages-dev']) as $pkg) { - if (isset($pkg['name']) && $pkg['name'] === 'psy/psysh') { -- // We're inside a project which requires psysh. We'll -- // use the local Composer autoload. +- // We're inside a project which requires psysh. We'll use the local Composer autoload. - if (is_file($path . '/vendor/autoload.php')) { +- if (realpath($path . '/vendor') !== realpath(__DIR__ . '/../../..')) { +- fwrite(STDERR, 'Using local PsySH version at ' . $prettyPath . PHP_EOL); +- } +- - require $path . '/vendor/autoload.php'; - } - @@ -85,8 +95,8 @@ index 4fbd223..ef7b940 100755 - } elseif (is_file(__DIR__ . '/../../../autoload.php')) { - require __DIR__ . '/../../../autoload.php'; - } else { -- echo 'PsySH dependencies not found, be sure to run `composer install`.' . PHP_EOL; -- echo 'See https://getcomposer.org to get Composer.' . PHP_EOL; +- fwrite(STDERR, 'PsySH dependencies not found, be sure to run `composer install`.' . PHP_EOL); +- fwrite(STDERR, 'See https://getcomposer.org to get Composer.' . PHP_EOL); - exit(1); - } -/* >>> */ @@ -95,23 +105,23 @@ index 4fbd223..ef7b940 100755 // If the psysh binary was included directly, assume they just wanted an // autoloader and bail early. -@@ -115,21 +31,5 @@ if (Psy\Shell::isIncluded($trace)) { +@@ -128,21 +34,5 @@ if (Psy\Shell::isIncluded($trace)) { // Clean up after ourselves. unset($trace); -// If the local version is too old, we can't do this -if (!function_exists('Psy\bin')) { -- $argv = $_SERVER['argv']; +- $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array(); - $first = array_shift($argv); - if (preg_match('/php(\.exe)?$/', $first)) { - array_shift($argv); - } - array_unshift($argv, 'vendor/bin/psysh'); - -- echo 'A local PsySH dependency was found, but it cannot be loaded. Please update to' . PHP_EOL; -- echo 'the latest version, or run the local copy directly, e.g.:' . PHP_EOL; -- echo PHP_EOL; -- echo ' ' . implode(' ', $argv) . PHP_EOL; +- fwrite(STDERR, 'A local PsySH dependency was found, but it cannot be loaded. Please update to' . PHP_EOL); +- fwrite(STDERR, 'the latest version, or run the local copy directly, e.g.:' . PHP_EOL); +- fwrite(STDERR, PHP_EOL); +- fwrite(STDERR, ' ' . implode(' ', $argv) . PHP_EOL); - exit(1); -} - -- cgit