From: Stig Bakken Date: Sat, 27 Oct 2001 07:52:12 +0000 (+0000) Subject: * actually implement -s/-S options :-) X-Git-Tag: ChangeLog~519 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd0fb34562c25c9074b0cd5185d6857983958c8d;p=php * actually implement -s/-S options :-) --- diff --git a/pear/PEAR/Config.php b/pear/PEAR/Config.php index 6c36e9b981..88f6e9bbcf 100644 --- a/pear/PEAR/Config.php +++ b/pear/PEAR/Config.php @@ -80,9 +80,10 @@ class PEAR_Config extends PEAR if (!$fp) { return $this->raiseError($php_errormsg); } - $contents = fread($fp, filesize($file)); + $size = filesize($file); + $contents = fread($fp, $size); $data = unserialize($contents); - if ($data === false) { + if ($data === false && $size > 1) { return $this->raiseError("PEAR_Config::readConfigFile: bad data"); } $this->configuration = $data; @@ -123,10 +124,10 @@ class PEAR_Config extends PEAR function writeConfigFile($file = null, $what_keys = 'userdefined') { - print "storing $what_keys keys\n"; if ($what_keys == 'both') { $this->writeConfigFile($file, 'userdefined'); $this->writeConfigFile($file, 'default'); + return; } if ($file === null) { if ($what_keys == 'default') { @@ -150,7 +151,7 @@ class PEAR_Config extends PEAR } $fp = @fopen($file, "w"); if (!$fp) { - return $this->raiseError("PEAR_Config::writeConfigFile fopen failed"); + return $this->raiseError("PEAR_Config::writeConfigFile fopen('$file','w') failed"); } if (!@fwrite($fp, serialize($data))) { return $this->raiseError("PEAR_Config::writeConfigFile serialize failed"); diff --git a/pear/scripts/pear.in b/pear/scripts/pear.in index ecdfa88102..5cd2633224 100644 --- a/pear/scripts/pear.in +++ b/pear/scripts/pear.in @@ -24,6 +24,8 @@ require_once 'Console/Getopt.php'; error_reporting(E_ALL ^ E_NOTICE); +PEAR::setErrorHandling(PEAR_ERROR_PRINT, "pear: %s\n"); + // {{{ config file and option parsing $options = Console_Getopt::getopt($argv, "c:C:d:D:h?sS"); @@ -76,6 +78,18 @@ foreach ($opts as $opt) { } } +if ($store_default_config) { + if (@is_writeable($pear_default_config)) { + $config->writeConfigFile($pear_default_config, 'default'); + } else { + die("You don't have write access to $pear_default_config, exiting!\n"); + } +} + +if ($store_user_config) { + $config->writeConfigFile($pear_user_config, 'userdefined'); +} + $fallback_config = array( 'php_dir' => PEAR_INSTALL_DIR, 'ext_dir' => PEAR_EXTENSION_DIR, @@ -96,8 +110,6 @@ $doc_dir = $config->get("doc_dir"); // }}} -PEAR::setErrorHandling(PEAR_ERROR_PRINT, "pear: %s\n"); - $command = $options[1][1]; switch ($command) { // {{{ install