[PATCH 1/3] cyradm: repair server metadata output

Norbert Warmuth now at arcor.de
Sun Mar 29 13:31:30 EDT 2015


server metadata is printed with some strange format. Instead of one
section header "Server Wide" multiple section headers are printed:
    cyradm> info
    Server Wide:
      admin: NIL
    admin:
      comment: NIL
    comment:
      motd: NIL
    motd:
      expire: NIL

More correct output would be:
    cyradm> info
    Server Wide:
      admin: NIL
      comment: NIL
      motd: NIL
      expire: NIL

Following two lines in Shell.pm
    $attrib =~ /(\{.*\})/;
    my $sect = $1;
do not work as intented because
- server metadata does not contain '{}'.
- the regular expression does not match, i. e. perl does not reset capture
  groups and $1 still references the last successful match form the previous
  loop ("$attrib =~ /([^\/]*)$/;" at the end of the loop).
---
 perl/imap/IMAP/Shell.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/perl/imap/IMAP/Shell.pm b/perl/imap/IMAP/Shell.pm
index a1448f7..0240d41 100644
--- a/perl/imap/IMAP/Shell.pm
+++ b/perl/imap/IMAP/Shell.pm
@@ -1387,8 +1387,9 @@ sub _sc_info {
   # keep track of what mailboxes we've printed a header for already
   my %section = ();
   foreach my $attrib (sort keys %info) {
-    $attrib =~ /(\{.*\})/;
-    my $sect = $1;
+    # server metadata does not contain '{}'
+    my $sect = undef;
+    $sect = $1 if $attrib =~ /(\{.*\})/;
     if(!defined($sect)) {
 	$sect = "Server Wide";
     }
-- 
2.1.4




More information about the Cyrus-devel mailing list