misc/158725: `column -t` always separates columns by 2 chars

Bela Lubkin filbo_freebsd at armory.com
Fri Jul 8 09:20:02 UTC 2011


>Number:         158725
>Category:       misc
>Synopsis:       `column -t` always separates columns by 2 chars
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 08 09:20:01 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Bela Lubkin
>Release:        none
>Organization:
myself
>Environment:
Linux albatross 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:05:41 UTC 2011 i686 i686 i386 GNU/Linux
(well, you asked...)
>Description:
`column -t` always separates columns by 2 chars:

$ echo "a b c" | column -t
a  b  c

I almost always want 1-space separation.  Might as well make this tunable...
>How-To-Repeat:
Use `column -t` at all.
>Fix:
Attached patch is against Ubuntu 11.04 "bsdmainutils", which originated in FreeBSD somewhere long ago.  Will need at least slight changes to apply to FreeBSD (man page mentions the Debian-added "-n" flag, although usage() does not...)

Patch attached with submission follows:

========== diff -U1 usr.bin/column/column.c.orig usr.bin/column/column.c ==========
--- usr.bin/column/column.c.orig	2011-07-08 01:29:43.000000000 -0700
+++ usr.bin/column/column.c	2011-07-08 01:43:53.000000000 -0700
@@ -75,2 +75,4 @@
 
+int between = 2;		/* default blanks between columns */
+
 int entries;			/* number of records */
@@ -101,3 +103,3 @@
 	tflag = xflag = 0;
-	while ((ch = getopt(argc, argv, "c:s:txn")) != -1)
+	while ((ch = getopt(argc, argv, "b:c:s:txn")) != -1)
 		switch(ch) {
@@ -109,2 +111,7 @@
 			break;
+		case 'b':
+			between = atoi(optarg);
+			if (between < 1)
+				errx(1, "`between' must be greater than 0");
+			break;
 		case 's':
@@ -307,3 +314,3 @@
 			(void)wprintf(L"%ls%*ls", t->list[coloff] ? t->list[coloff] : L"",
-			    lens[coloff] - t->len[coloff] + 2, L" ");
+			    lens[coloff] - t->len[coloff] + between, L" ");
 		(void)wprintf(L"%ls\n", t->list[coloff] ? t->list[coloff] : L"");
@@ -370,3 +377,3 @@
 	(void)fprintf(stderr,
-	    "usage: column [-tx] [-c columns] [-s sep] [file ...]\n");
+	    "usage: column [-tx] [-b between] [-c columns] [-s sep] [file ...]\n");
 	exit(1);
========== diff -U1 usr.bin/column/column.1.orig usr.bin/column/column.1 ==========
--- usr.bin/column/column.1.orig	2011-07-08 01:29:43.000000000 -0700
+++ usr.bin/column/column.1	2011-07-08 02:10:43.000000000 -0700
@@ -43,2 +43,3 @@
 .Op Fl ntx
+.Op Fl b Ar between
 .Op Fl c Ar columns
@@ -58,2 +59,8 @@
 .Bl -tag -width indent
+.It Fl b
+Columns in
+.Fl t
+output are separated by
+.Ar between
+space characters (default 2).
 .It Fl c


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list