summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2001-10-27 07:52:12 +0000
committerStig Bakken <ssb@php.net>2001-10-27 07:52:12 +0000
commitcd0fb34562c25c9074b0cd5185d6857983958c8d (patch)
tree0177a194c6cd8d5802a4aa2eed34b60938478108
parent4a99c5ee5c7905eae97c59783c4f792b70aebfff (diff)
downloadphp-git-cd0fb34562c25c9074b0cd5185d6857983958c8d.tar.gz
* actually implement -s/-S options :-)
-rw-r--r--pear/PEAR/Config.php9
-rw-r--r--pear/scripts/pear.in16
2 files changed, 19 insertions, 6 deletions
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