Skip to content
Permalink
Browse files

Better handling of phar archives

This fixes a bug that prevented compressed archives & archives whose file
extension had been modified from running.
  • Loading branch information...
fpoirotte committed May 12, 2018
1 parent 282de33 commit 4c5ef93ca73b7a010c2a3793cca0b9be218fcebf
Showing with 14 additions and 15 deletions.
  1. +14 −15 bin/xrl
29 bin/xrl
@@ -38,26 +38,25 @@ foreach ($extensions as $ext) {
DIRECTORY_SEPARATOR . 'autoload.php'
);
if (!strncasecmp(substr(__FILE__, -5), '.phar', 5)) {
try {
Phar::mapPhar();
} catch (Exception $e) {
echo "Cannot process XRL phar:" . PHP_EOL;
echo $e->getMessage() . PHP_EOL;
exit -1;
}
$error = new \RuntimeException();
try {
Phar::mapPhar();
$base = 'phar://' . __FILE__;
} else {
} catch (\Exception $error) {
$base = dirname(__DIR__);
}
$autoload = $base .
DIRECTORY_SEPARATOR . 'src' .
DIRECTORY_SEPARATOR . 'Autoload.php';
if (!class_exists('\\fpoirotte\\XRL\\Autoload')) {
require_once(
$base .
DIRECTORY_SEPARATOR . 'src' .
DIRECTORY_SEPARATOR . 'Autoload.php'
);
\fpoirotte\XRL\Autoload::register();
if (file_exists($autoload)) {
require_once($autoload);
\fpoirotte\XRL\Autoload::register();
} else {
echo "Cannot process the archive: " . $error->getMessage() . PHP_EOL;
exit -1;
}
}
$cli = new \fpoirotte\XRL\CLI();

0 comments on commit 4c5ef93

Please sign in to comment.
You can’t perform that action at this time.