Skip to content

Commit

Permalink
Fixed unwanted output during search for 7z/7zr command
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Manley committed Aug 15, 2023
1 parent cb8535e commit e4fa65a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions SevenZipArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @author Craig Manley
* @copyright Copyright © 2014, Craig Manley (www.craigmanley.com)
* @license http://www.opensource.org/licenses/mit-license.php Licensed under MIT
* @version 1.10
* @version 1.11
* @package cmanley
*/

Expand Down Expand Up @@ -117,13 +117,19 @@ function __construct($file, array $options = null) {
else {
foreach ([
'7zr', # Debian
'7z', # Alpine (untested)
'7z', # Alpine (untested), and Debian
] as $candidate) {
$rc = null;
$bin = system("command -v $candidate", $rc);
if ($bin && ($rc == 0)) {
$this->binary = $bin;
break;
$bin = null;
if (1) {
$cmd = 'command -v ' . escapeshellarg($candidate);
$output = array();
$rc = null;
exec($cmd, $output, $rc);
$this->debug && error_log(__METHOD__ . " $cmd: rc=$rc");
if (!$rc && $output) {
$this->binary = end($output);
break;
}
}
}
if (!$this->binary) {
Expand Down

0 comments on commit e4fa65a

Please sign in to comment.