Fix handling of --delete argument in moduserprefs.sh script (#5296)

pull/5754/head
Aleksander Machniak 8 years ago
parent e2278a3c1c
commit 06d09b23c6

@ -13,6 +13,7 @@ CHANGELOG Roundcube Webmail
- Fix bug where "no body" alert could be displayed when sending mailvelope email
- Enigma: Fix keys import from inside of an encrypted message (#5285)
- Fix searching by email address in contacts with multiple addresses (#5291)
- Fix handling of --delete argument in moduserprefs.sh script (#5296)
RELEASE 1.2.0
-------------

@ -36,7 +36,7 @@ function print_usage()
// get arguments
$args = rcube_utils::get_opt(array(
'u' => 'user',
'd' => 'delete',
'd' => 'delete:bool',
't' => 'type',
'c' => 'config',
));
@ -45,7 +45,7 @@ if ($_SERVER['argv'][1] == 'help') {
print_usage();
exit;
}
else if (empty($args[0]) || (!isset($args[1]) && !$args['delete'])) {
else if (empty($args[0]) || (empty($args[1]) && empty($args['delete']))) {
print "Missing required parameters.\n";
print_usage();
exit;

@ -24,7 +24,7 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments
$opts = rcube_utils::get_opt(array('v' => 'version', 'y' => 'accept'));
$opts = rcube_utils::get_opt(array('v' => 'version', 'y' => 'accept:bool'));
// ask user if no version is specified
if (!$opts['version']) {

@ -976,6 +976,16 @@ class rcube_utils
public static function get_opt($aliases = array())
{
$args = array();
$bool = array();
// find boolean (no value) options
foreach ($aliases as $key => $alias) {
if ($pos = strpos($alias, ':')) {
$aliases[$key] = substr($alias, 0, $pos);
$bool[] = $key;
$bool[] = $aliases[$key];
}
}
for ($i=1; $i < count($_SERVER['argv']); $i++) {
$arg = $_SERVER['argv'][$i];
@ -985,10 +995,14 @@ class rcube_utils
if ($arg[0] == '-') {
$key = preg_replace('/^-+/', '', $arg);
$sp = strpos($arg, '=');
if ($sp > 0) {
$key = substr($key, 0, $sp - 2);
$value = substr($arg, $sp+1);
}
else if (in_array($key, $bool)) {
$value = true;
}
else if (strlen($_SERVER['argv'][$i+1]) && $_SERVER['argv'][$i+1][0] != '-') {
$value = $_SERVER['argv'][++$i];
}

Loading…
Cancel
Save