Patch for "doveadm -f table" nit (was Re: Dovecot current number of connections being used.)

Joseph Tam jtam.home at gmail.com
Thu Mar 19 00:37:58 UTC 2015


> doveadm who -1 2>/dev/null | wc -l

You have to redirect stderr to /dev/null because that's where the
first header line is written to.  The default format style (table)
is inconsistent with the other formats (flow,pager,tab) that write
headers and data to stdout.

The following patch will pick this nit.  This patch will require
modifications to scripts that rely on doveadm writing headers to stderr.
For example, the above doveadm command could be modified to

 	doveadm who -1 | grep -vc '^username'

--------------------------------------------------------------------------------
--- a/dovecot-2.2.16.rc1/src/doveadm/doveadm-print-table.c	Wed Mar 18 15:40:40 2015
+++ b/dovecot-2.2.16.rc1/src/doveadm/doveadm-print-table.c	Wed Mar 18 15:41:18 2015
@@ -151,3 +151,3 @@
  	for (i = 0; i < count; i++) {
-		if (i > 0) fprintf(stderr, " ");
+		if (i > 0) printf(" ");

@@ -155,3 +155,3 @@
  		     DOVEADM_PRINT_HEADER_FLAG_RIGHT_JUSTIFY) == 0) {
-			fprintf(stderr, "%-*s", (int)headers[i].length,
+			printf("%-*s", (int)headers[i].length,
  				headers[i].title);
@@ -158,3 +158,3 @@
  		} else {
-			fprintf(stderr, "%*s", (int)headers[i].length,
+			printf("%*s", (int)headers[i].length,
  				headers[i].title);
@@ -162,3 +162,3 @@
  	}
-	fprintf(stderr, "\n");
+	printf("\n");
  }
--------------------------------------------------------------------------------

Joseph Tam <jtam.home at gmail.com>


More information about the dovecot mailing list