Skip to content

cyradm "Negative repeat count does nothing at ..." for long folders in listmailbox output #5580

@MASHtm

Description

@MASHtm

Since cyradm uses now "use warnings"/-w it outputs (on 3.8.6 here)
Negative repeat count does nothing at ... /Shell.pm line 689
referencing the line

        $lfh->[1]->print($l[$l + $c], ' ' x ($w + 1 - length($l[$l + $c])));

in _sc_list() for every mailbox longer then 79 chars.
The whole codeblock tries to make a fancy "ls"-style output using "multi columns" if place is available.
But it does it with fixed width 79 meanwhile since $ENV{COLUMNS} is not set by modern shells anymore.

So either Term::ReadKey->GetTerminalSize can be used in combination of preventing negative values for the "x" operator...
or the block can be removed and replaced by a simple "one line per mailbox" output.

I did the "or"... note that I also removed the sort for the l array since it destroys the "improved mailbox sort order" ...

--- cyrus-imapd-3.8.6/perl/imap/IMAP/Shell.pm.orig      2025-08-19 11:58:49.963537795 +0200
+++ cyrus-imapd-3.8.6/perl/imap/IMAP/Shell.pm   2025-08-19 11:59:22.052972678 +0200
@@ -680,18 +680,8 @@
     push(@l, $l);
   }
   return 1 if !@l;
-  @l = sort {$a cmp $b} @l;
-  my $ll = $ENV{COLUMNS} || 79;
-  $w = $ll if $w > $ll;
-  my $n = int($ll / $w);
-  my $c;
-  for ($l = 0; $l < int((@l + $n - 1) / $n); $l++) {
-    for ($c = 0; $c < @l; $c += int((@l + $n - 1) / $n)) {
-      if ($l + $c < @l) {
-        $lfh->[1]->print($l[$l + $c], ' ' x ($w + 1 - length($l[$l + $c])));
-      }
-    }
-    $lfh->[1]->print("\n");
+  foreach $l (@l) {
+    $lfh->[1]->print($l."\n");
   }
   0;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions