more on #92263, dpkg --list truncates package names
This bug report, is wrongly labeled as "wishlist". It should be
"important", because it makes dpkg useless: If the package name is
truncated, you've lost the information you were trying to get from
dpkg-query.
More generally, unix programs should never truncate their output to fit
a terminal. Terminals are irrelevent; pipes are everything.
Here's a small patch that adds a --wide option to dpkg-query to print
without truncation.
--- query.c.orig 2004-11-11 12:10:03.000000000 -0800
+++ query.c 2004-12-25 16:30:24.000000000 -0800
@@ -120,6 +120,10 @@
return ws.ws_col;
}
+/* Behave like a proper unix command; don't truncate
+ output based on (assumed) terminal size. */
+static int widemode = 0;
+
static void list1package(struct pkginfo *pkg, int *head) {
int l,w;
static int nw,vw,dw;
@@ -133,7 +137,10 @@
nw=(14+w); /* name width */
vw=(14+w); /* version width */
dw=(44+(2*w)); /* description width */
- sprintf(format,"%%c%%c%%c %%-%d.%ds %%-%d.%ds %%.*s\n", nw, nw, vw, vw);
+ if (widemode)
+ sprintf(format,"%%c%%c%%c %%-%ds %%-%ds %%.*s\n", nw, vw);
+ else
+ sprintf(format,"%%c%%c%%c %%-%d.%ds %%-%d.%ds %%.*s\n", nw, nw, vw, vw);
}
if (!*head) {
@@ -150,7 +157,8 @@
*head= 1;
}
if (!pkg->installed.valid) blankpackageperfile(&pkg->installed);
- limiteddescription(pkg,dw,&pdesc,&l);
+ limiteddescription(pkg,widemode ? 99999 : dw,&pdesc,&l);
+
printf(format,
"uihrp"[pkg->want],
"nUFiHc"[pkg->status],
@@ -524,6 +532,8 @@
ACTION( "search", 'S', act_searchfiles, searchfiles ),
ACTION( "show", 'W', act_listpackages, showpackages ),
+ { "wide", 'w', 0, &widemode, 0, 0, 1 },
+
{ "admindir", 0, 1, 0, &admindir, 0 },
{ "showformat", 0, 1, 0, &showformat, 0 },
{ "help", 'h', 0, 0, 0, helponly },
Reply to: