From unknown Thu Sep 11 11:56:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20442: bug+patch: du output misaligned on different terminals Resent-From: "L. A. Walsh" Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 27 Apr 2015 19:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 20442 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 20442@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.143016190417526 (code B ref -1); Mon, 27 Apr 2015 19:12:01 +0000 Received: (at submit) by debbugs.gnu.org; 27 Apr 2015 19:11:44 +0000 Received: from localhost ([127.0.0.1]:41526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YmoRT-0004Yb-KH for submit@debbugs.gnu.org; Mon, 27 Apr 2015 15:11:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38764) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YmoRR-0004YL-1V for submit@debbugs.gnu.org; Mon, 27 Apr 2015 15:11:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmoRK-0007ar-Gt for submit@debbugs.gnu.org; Mon, 27 Apr 2015 15:11:35 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmoRK-0007an-EK for submit@debbugs.gnu.org; Mon, 27 Apr 2015 15:11:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmoRJ-0008Sb-6P for bug-coreutils@gnu.org; Mon, 27 Apr 2015 15:11:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmoRE-0007aJ-TJ for bug-coreutils@gnu.org; Mon, 27 Apr 2015 15:11:33 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:49268 helo=Ishtar.hs.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmoRE-0007a4-As for bug-coreutils@gnu.org; Mon, 27 Apr 2015 15:11:28 -0400 Received: from [192.168.4.12] (Athenae [192.168.4.12]) by Ishtar.hs.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id t3RJBNc9037911 for ; Mon, 27 Apr 2015 12:11:26 -0700 Message-ID: <553E89DA.4060206@tlinx.org> Date: Mon, 27 Apr 2015 12:11:22 -0700 From: "L. A. Walsh" User-Agent: Thunderbird MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090201000507000905060400" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is a multi-part message in MIME format. --------------090201000507000905060400 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit This is a fix/work-around for (RFE#19849 (bug#19849) which was about addingg options to expand tabs and/or set a tabsize for output from 'du' so output would line up as intended. Without that enhancement, the current output is "messed up" on terminals/consoles that don't use hard-coded-constant widths for tabs (like many or most of the Xterm & linux consoles). Adding the switches is more work than I want to chew off right now, but the misaligned output made for difficult reading (besides looking bad), especially w/a monospace font where it is clear that the columns were meant to lineup. So I threw together a quick patch against the current git source (changes limited to 'du.c'). If someone would look it over, try it, or such and apply it to the current coreutils source tree (it's in patch form against 'src/du.c') for some soon future release, (at least until such time as the above mentioned RFE can be addressed). 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 The current du output (example from my tmp dir) on a term w/o hard-coded-constant expansion looks like: Ishtar:tools/coreutils/work/src> /usr/bin/du /tmp/t* 4 /tmp/t 1160 /tmp/t1 680 /tmp/t2 4 /tmp/tab2.patch 20 /tmp/tabs 4 /tmp/tmpf 4 /tmp/topcmds 24 /tmp/topcmds-hlps 24 /tmp/topcmds2 8 /tmp/topcmds2.txt 4 /tmp/tq1 32 /tmp/tt 32 /tmp/tt *Without* the assumption of hard-coded or fixed tabs (using a 8-spaces/tab as seems to be the implementors assumption / intention), the output columns, again, line-up vertically: Ishtar:tools/coreutils/work/src> ./du /tmp/t* 4 /tmp/t 1160 /tmp/t1 680 /tmp/t2 4 /tmp/tab2.patch 20 /tmp/tabs 4 /tmp/tmpf 4 /tmp/topcmds 24 /tmp/topcmds-hlps 24 /tmp/topcmds2 8 /tmp/topcmds2.txt 4 /tmp/tq1 32 /tmp/tt While not addressing the RFE, at least the original output format should look the same on all terminals Thanks, Linda Walsh (FWIW - the patch may be used under the same license as the rest of 'du.c'). --------------090201000507000905060400 Content-Type: text/plain; name="du_Xpandtab.patch" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="du_Xpandtab.patch" LS0tIHNyYy9kdS5jCTIwMTUtMDQtMDEgMTc6MzE6MDIuMDAwMDAwMDAwIC0wNzAwCisrKyBz cmMvZHUuYwkyMDE1LTA0LTI2IDE2OjE2OjQzLjgyOTYwMjg0MyAtMDcwMApAQCAtMSwzICsx LDQgQEAKKwogLyogZHUgLS0gc3VtbWFyaXplIGRpc2sgdXNhZ2UKICAgIENvcHlyaWdodCAo QykgMTk4OC0yMDE1IEZyZWUgU29mdHdhcmUgRm91bmRhdGlvbiwgSW5jLgogCkBAIC0zNzAs NTIgKzM3MSw4NiBAQAogCiAvKiBGSVhNRTogdGhpcyBjb2RlIGlzIG5lYXJseSBpZGVudGlj YWwgdG8gY29kZSBpbiBkYXRlLmMgICovCiAvKiBEaXNwbGF5IHRoZSBkYXRlIGFuZCB0aW1l IGluIFdIRU4gYWNjb3JkaW5nIHRvIHRoZSBmb3JtYXQgc3BlY2lmaWVkCi0gICBpbiBGT1JN QVQuICAqLworICAgaW4gRk9STUFULgorICAgTm90ZSBtb2RpZmljYXRpbm8gdG8gcmV0dXJu ICMgb2YgY2hhcnMgKGV4Y2x1c2l2ZSBvZiBOVUwpICAqLwogCi1zdGF0aWMgdm9pZAorc3Rh dGljIGludAogc2hvd19kYXRlIChjb25zdCBjaGFyICpmb3JtYXQsIHN0cnVjdCB0aW1lc3Bl YyB3aGVuKQogewogICBzdHJ1Y3QgdG0gKnRtID0gbG9jYWx0aW1lICgmd2hlbi50dl9zZWMp OworICBpbnQgc2xlbiA9IDA7CiAgIGlmICghIHRtKQogICAgIHsKICAgICAgIGNoYXIgYnVm W0lOVF9CVUZTSVpFX0JPVU5EIChpbnRtYXhfdCldOwogICAgICAgY2hhciAqd2hlbl9zdHIg PSB0aW1ldG9zdHIgKHdoZW4udHZfc2VjLCBidWYpOwogICAgICAgZXJyb3IgKDAsIDAsIF8o InRpbWUgJXMgaXMgb3V0IG9mIHJhbmdlIiksIHdoZW5fc3RyKTsKKyAgICAgIHNsZW49c3Ry bGVuKHdoZW5fc3RyKTsKICAgICAgIGZwdXRzICh3aGVuX3N0ciwgc3Rkb3V0KTsKLSAgICAg IHJldHVybjsKKyAgICAgIHJldHVybiBzbGVuOwogICAgIH0KIAotICBmcHJpbnRmdGltZSAo c3Rkb3V0LCBmb3JtYXQsIHRtLCAwLCB3aGVuLnR2X25zZWMpOworICBzbGVuICs9IGZwcmlu dGZ0aW1lIChzdGRvdXQsIGZvcm1hdCwgdG0sIDAsIHdoZW4udHZfbnNlYyk7CisgIHJldHVy biBzbGVuOwogfQogCiAvKiBQcmludCBOX0JZVEVTLiAgQ29udmVydCBpdCB0byBhIHJlYWRh YmxlIHZhbHVlIGJlZm9yZSBwcmludGluZy4gICovCiAKLXN0YXRpYyB2b2lkCitzdGF0aWMg aW50CiBwcmludF9vbmx5X3NpemUgKHVpbnRtYXhfdCBuX2J5dGVzKQogewogICBjaGFyIGJ1 ZltMT05HRVNUX0hVTUFOX1JFQURBQkxFICsgMV07Ci0gIGZwdXRzICgobl9ieXRlcyA9PSBV SU5UTUFYX01BWAorCWNoYXIgKiBvdXRwOworICBmcHV0cyAob3V0cCA9ICgobl9ieXRlcyA9 PSBVSU5UTUFYX01BWAogICAgICAgICAgID8gXygiSW5maW5pdHkiKQogICAgICAgICAgIDog aHVtYW5fcmVhZGFibGUgKG5fYnl0ZXMsIGJ1ZiwgaHVtYW5fb3V0cHV0X29wdHMsCi0gICAg ICAgICAgICAgICAgICAgICAgICAgICAgMSwgb3V0cHV0X2Jsb2NrX3NpemUpKSwKKyAgICAg ICAgICAgICAgICAgICAgICAgICAgICAxLCBvdXRwdXRfYmxvY2tfc2l6ZSkpKSwKICAgICAg ICAgIHN0ZG91dCk7CisJcmV0dXJuIHN0cmxlbihvdXRwKTsKK30KKworCisvKiB1c2luZyBi dWYgb2YgbGVuICduJywgcmV0dXJuIGEgbnVsLXRlcm0uIHN0cmluZyB3LyMgc3BhY2VzIHRv IGlucyBmb3IgdGFiLgorICogSWYgdGFic2l6ZSBpcyAwLCBhIDAtbGVuIHN0cmluZyB3aWxs IGJlIHJldHVybmVkLgorICovCisKK3N0YXRpYyBjaGFyICoKK3RhYm5zcGFjZXMoY2hhciAq IGJ1ZiwgaW50IG4sIGludCBjdXJfb3V0cHV0X2xlbiwgaW50IHRhYnNpemUpCit7CisgIGNo YXIgKiBvYnVmID0gYnVmOworICBpbnQgc3BhY2VzID0gIHRhYnNpemUgPyB0YWJzaXplIC0g KGN1cl9vdXRwdXRfbGVuICUgdGFic2l6ZSkgOiAwOworCisgIGlmICghbikgcmV0dXJuIE5V TEw7CisKKyAgLyogcHJlLWRlYyAnbicgdG8gcmVzZXJ2ZSBzcGFjZSBmb3IgbnVsICovCisg IHdoaWxlKC0tbiA+IDAgICYmICBzcGFjZXMtLSA+IDApICpvYnVmKysgPSAnICc7CisgICpv YnVmID0gJ1wwJzsKKyAgcmV0dXJuIGJ1ZjsKIH0KIAogLyogUHJpbnQgc2l6ZSAoYW5kIG9w dGlvbmFsbHkgdGltZSkgaW5kaWNhdGVkIGJ5ICpQRFVJLCBmb2xsb3dlZCBieSBTVFJJTkcu ICAqLwogCitpbnQgdGVybV90YWJzaXplID0gODsgLyogZGVmYXVsdCBmb3Igbm93ICovCisK IHN0YXRpYyB2b2lkCiBwcmludF9zaXplIChjb25zdCBzdHJ1Y3QgZHVpbmZvICpwZHVpLCBj b25zdCBjaGFyICpzdHJpbmcpCiB7Ci0gIHByaW50X29ubHlfc2l6ZSAob3B0X2lub2Rlcwot ICAgICAgICAgICAgICAgICAgID8gcGR1aS0+aW5vZGVzCi0gICAgICAgICAgICAgICAgICAg OiBwZHVpLT5zaXplKTsKKwlpbnQgcHJpbnRfbGVuID0gcHJpbnRfb25seV9zaXplIChvcHRf aW5vZGVzCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gcGR1aS0+aW5v ZGVzCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogcGR1aS0+c2l6ZSk7 CisgIGNoYXIgWHRhYlsxMDI0XTsgIC8qIFhwYW5kZWQgdGFiICovCisgIGNoYXIgKiBteXNw YWNlczsKIAogICBpZiAob3B0X3RpbWUpCiAgICAgewotICAgICAgcHV0Y2hhciAoJ1x0Jyk7 Ci0gICAgICBzaG93X2RhdGUgKHRpbWVfZm9ybWF0LCBwZHVpLT50bWF4KTsKKyAgCQlteXNw YWNlcyA9IHRhYm5zcGFjZXMoWHRhYiwgc2l6ZW9mKFh0YWIpLCBwcmludF9sZW4sIHRlcm1f dGFic2l6ZSk7CisJCQlwcmludF9sZW4rPXN0cmxlbihteXNwYWNlcyk7CisgICAgICBmcHV0 cyAobXlzcGFjZXMsIHN0ZG91dCk7CisgICAgICBwcmludF9sZW4rPSBzaG93X2RhdGUgKHRp bWVfZm9ybWF0LCBwZHVpLT50bWF4KTsKICAgICB9Ci0gIHByaW50ZiAoIlx0JXMlYyIsIHN0 cmluZywgb3B0X251bF90ZXJtaW5hdGVfb3V0cHV0ID8gJ1wwJyA6ICdcbicpOworIAorICBt eXNwYWNlcyA9IHRhYm5zcGFjZXMoWHRhYiwgc2l6ZW9mKFh0YWIpLCBwcmludF9sZW4sIHRl cm1fdGFic2l6ZSk7CisgIGZwdXRzKG15c3BhY2VzLCBzdGRvdXQpOworICBwcmludGYgKCIl cyVjIiwgc3RyaW5nLCBvcHRfbnVsX3Rlcm1pbmF0ZV9vdXRwdXQgPyAnXDAnIDogJ1xuJyk7 CiAgIGZmbHVzaCAoc3Rkb3V0KTsKIH0KIAo= --------------090201000507000905060400-- From unknown Thu Sep 11 11:56:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20442: bug+patch: du output misaligned on different terminals Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 27 Apr 2015 23:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20442 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "L. A. Walsh" , 20442@debbugs.gnu.org Received: via spool by 20442-submit@debbugs.gnu.org id=B20442.143017802432413 (code B ref 20442); Mon, 27 Apr 2015 23:41:02 +0000 Received: (at 20442) by debbugs.gnu.org; 27 Apr 2015 23:40:24 +0000 Received: from localhost ([127.0.0.1]:41767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YmsdS-0008Qe-Qn for submit@debbugs.gnu.org; Mon, 27 Apr 2015 19:40:24 -0400 Received: from mail5.vodafone.ie ([213.233.128.176]:53751) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YmsdP-0008Q7-3O for 20442@debbugs.gnu.org; Mon, 27 Apr 2015 19:40:20 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtcKAOnHPlVtT0tl/2dsb2JhbABWBoMJhEnIJ4JdAoEwTAEBAQEBAYELQQWDWwEBBCMPAVYLDQsCAgUhAgIPAkYGAQwIAQGIKwGzJIVojjgBCyCBIYoXhCwWSoJogUUFo12OEiOBZYIQPYEzgUIBAQE Received: from unknown (HELO localhost.localdomain) ([109.79.75.101]) by mail3.vodafone.ie with ESMTP; 28 Apr 2015 00:40:10 +0100 Message-ID: <553EC8DA.50906@draigBrady.com> Date: Tue, 28 Apr 2015 00:40:10 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 References: <553E89DA.4060206@tlinx.org> In-Reply-To: <553E89DA.4060206@tlinx.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) tag 20442 wontfix close 20442 stop On 27/04/15 20:11, L. A. Walsh wrote: > > > > This is a fix/work-around for (RFE#19849 (bug#19849) which was > about addingg options to expand tabs and/or set a tabsize > for output from 'du' so output would line up as intended. > > Without that enhancement, the current output is "messed > up" on terminals/consoles that don't use hard-coded-constant > widths for tabs (like many or most of the Xterm & linux > consoles). > > Adding the switches is more work than I want to chew > off right now, but the misaligned output made for difficult > reading (besides looking bad), especially w/a monospace font > where it is clear that the columns were meant to lineup. > So I threw together a quick patch against the current > git source (changes limited to 'du.c'). > > If someone would look it over, try it, or such and apply it > to the current coreutils source tree (it's in patch form > against 'src/du.c') for some soon future release, (at least > until such time as the above mentioned RFE can be addressed). > > 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 > The current du output (example from my tmp dir) on a > term w/o hard-coded-constant expansion looks like: > > Ishtar:tools/coreutils/work/src> /usr/bin/du /tmp/t* > 4 /tmp/t > 1160 /tmp/t1 > 680 /tmp/t2 > 4 /tmp/tab2.patch > 20 /tmp/tabs > 4 /tmp/tmpf > 4 /tmp/topcmds > 24 /tmp/topcmds-hlps > 24 /tmp/topcmds2 > 8 /tmp/topcmds2.txt > 4 /tmp/tq1 > 32 /tmp/tt > 32 /tmp/tt In fairness, this is with the unusual case after running `tabs 2` > *Without* the assumption of hard-coded or fixed tabs (using > a 8-spaces/tab as seems to be the implementors assumption / > intention), the output columns, again, line-up vertically: > > Ishtar:tools/coreutils/work/src> ./du /tmp/t* > 4 /tmp/t > 1160 /tmp/t1 > 680 /tmp/t2 > 4 /tmp/tab2.patch > 20 /tmp/tabs > 4 /tmp/tmpf > 4 /tmp/topcmds > 24 /tmp/topcmds-hlps > 24 /tmp/topcmds2 > 8 /tmp/topcmds2.txt > 4 /tmp/tq1 > 32 /tmp/tt > > > While not addressing the RFE, at least the original output format > should look the same on all terminals Thanks for the patch, however the same could be achieved more generally with external tools. For example numbers are better for human consumption when right aligned, so you could achieve both with: du | numfmt --format %10f cheers, Pádraig. From unknown Thu Sep 11 11:56:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20442: bug+patch: du output misaligned on different terminals Resent-From: Linda Walsh Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 28 Apr 2015 00:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20442 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , 20442@debbugs.gnu.org Received: via spool by 20442-submit@debbugs.gnu.org id=B20442.14301800216400 (code B ref 20442); Tue, 28 Apr 2015 00:14:02 +0000 Received: (at 20442) by debbugs.gnu.org; 28 Apr 2015 00:13:41 +0000 Received: from localhost ([127.0.0.1]:41783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ymt9g-0001fA-9j for submit@debbugs.gnu.org; Mon, 27 Apr 2015 20:13:40 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:47721 helo=Ishtar.hs.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ymt9e-0001f0-8H for 20442@debbugs.gnu.org; Mon, 27 Apr 2015 20:13:39 -0400 Received: from [192.168.4.12] (Athenae [192.168.4.12]) by Ishtar.hs.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id t3S0DXqi086815; Mon, 27 Apr 2015 17:13:36 -0700 Message-ID: <553ED0AD.8040004@tlinx.org> Date: Mon, 27 Apr 2015 17:13:33 -0700 From: Linda Walsh User-Agent: Thunderbird MIME-Version: 1.0 References: <553E89DA.4060206@tlinx.org> <553EC8DA.50906@draigBrady.com> In-Reply-To: <553EC8DA.50906@draigBrady.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) reopen 20442 thanks ======= Your more general case doesn't work: > du -sh /tmp/t*|numfmt --format %10f numfmt: rejecting suffix in input: ‘4.0K’ (consider using --from) > du -sh --time /tmp/t*|numfmt --format %10f numfmt: rejecting suffix in input: ‘4.0K’ (consider using --from) I usually use other arguments with 'du'. Your external tool solution doesn't handle the general case of "du's" output. The point was to correct 'du's output, not find a *custom* solution to correct assumptions made by 'du'. Why would you reject something that fixes this problem? Are you proposing to remove the special tab-handling in 'dir', 'ls', 'cat', 'expand', 'pr', 'unexpand', 'vdir' among many other cmdline utils? Relying on hard-coded constants is usually considered poor programming practice. In this case, you are relying on all terminals/output devices conforming to a fixed value that you deem correct. Is there a benefit to choosing an inferior design that doesn't work across different terminal sizes? The patch resolves the problem and works on all terminals. Pádraig Brady wrote: > tag 20442 wontfix > close 20442 > stop > > On 27/04/15 20:11, L. A. Walsh wrote: >> >> >> This is a fix/work-around for (RFE#19849 (bug#19849) which was >> about addingg options to expand tabs and/or set a tabsize >> for output from 'du' so output would line up as intended. >> >> Without that enhancement, the current output is "messed >> up" on terminals/consoles that don't use hard-coded-constant >> widths for tabs (like many or most of the Xterm & linux >> consoles). >> >> Adding the switches is more work than I want to chew >> off right now, but the misaligned output made for difficult >> reading (besides looking bad), especially w/a monospace font >> where it is clear that the columns were meant to lineup. >> So I threw together a quick patch against the current >> git source (changes limited to 'du.c'). >> >> If someone would look it over, try it, or such and apply it >> to the current coreutils source tree (it's in patch form >> against 'src/du.c') for some soon future release, (at least >> until such time as the above mentioned RFE can be addressed). >> >> 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 >> The current du output (example from my tmp dir) on a >> term w/o hard-coded-constant expansion looks like: >> >> Ishtar:tools/coreutils/work/src> /usr/bin/du /tmp/t* >> 4 /tmp/t >> 1160 /tmp/t1 >> 680 /tmp/t2 >> 4 /tmp/tab2.patch >> 20 /tmp/tabs >> 4 /tmp/tmpf >> 4 /tmp/topcmds >> 24 /tmp/topcmds-hlps >> 24 /tmp/topcmds2 >> 8 /tmp/topcmds2.txt >> 4 /tmp/tq1 >> 32 /tmp/tt >> 32 /tmp/tt > > In fairness, this is with the unusual case after running `tabs 2` > >> *Without* the assumption of hard-coded or fixed tabs (using >> a 8-spaces/tab as seems to be the implementors assumption / >> intention), the output columns, again, line-up vertically: >> >> Ishtar:tools/coreutils/work/src> ./du /tmp/t* >> 4 /tmp/t >> 1160 /tmp/t1 >> 680 /tmp/t2 >> 4 /tmp/tab2.patch >> 20 /tmp/tabs >> 4 /tmp/tmpf >> 4 /tmp/topcmds >> 24 /tmp/topcmds-hlps >> 24 /tmp/topcmds2 >> 8 /tmp/topcmds2.txt >> 4 /tmp/tq1 >> 32 /tmp/tt >> >> >> While not addressing the RFE, at least the original output format >> should look the same on all terminals > > Thanks for the patch, however the same could be achieved > more generally with external tools. For example numbers are > better for human consumption when right aligned, so you > could achieve both with: > > du | numfmt --format %10f > > cheers, > Pádraig. > From unknown Thu Sep 11 11:56:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20442: bug+patch: du output misaligned on different terminals Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 28 Apr 2015 00:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20442 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Linda Walsh , 20442@debbugs.gnu.org Received: via spool by 20442-submit@debbugs.gnu.org id=B20442.14301809388642 (code B ref 20442); Tue, 28 Apr 2015 00:29:02 +0000 Received: (at 20442) by debbugs.gnu.org; 28 Apr 2015 00:28:58 +0000 Received: from localhost ([127.0.0.1]:41803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YmtOT-0002FJ-GY for submit@debbugs.gnu.org; Mon, 27 Apr 2015 20:28:58 -0400 Received: from mail6.vodafone.ie ([213.233.128.184]:44122) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YmtOS-0002F0-0i for 20442@debbugs.gnu.org; Mon, 27 Apr 2015 20:28:56 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtkKAKLTPlVtT0tl/2dsb2JhbABcgwyEScgogl0CgTFMAQEBAQEBgQtBBYNaAQEBAwEjDwFLCwsNAQoCAgUWCwICCQMCAQIBRQYBDAgBAReICAwBsyWFaI46DCCBIYoXhFI6gmiBRQWdMIYtikKDUCOBZYIQPYJ1AQEB Received: from unknown (HELO localhost.localdomain) ([109.79.75.101]) by mail3.vodafone.ie with ESMTP; 28 Apr 2015 01:28:48 +0100 Message-ID: <553ED43F.1070705@draigBrady.com> Date: Tue, 28 Apr 2015 01:28:47 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 References: <553E89DA.4060206@tlinx.org> <553EC8DA.50906@draigBrady.com> <553ED0AD.8040004@tlinx.org> In-Reply-To: <553ED0AD.8040004@tlinx.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 28/04/15 01:13, Linda Walsh wrote: > reopen 20442 > thanks > ======= > > Your more general case doesn't work: > >> du -sh /tmp/t*|numfmt --format %10f > numfmt: rejecting suffix in input: ‘4.0K’ (consider using --from) >> du -sh --time /tmp/t*|numfmt --format %10f > numfmt: rejecting suffix in input: ‘4.0K’ (consider using --from) You can use: du -h --time | numfmt --from=iec --to=iec --format %10f Though more naturally you can use: du -B1 --time | numfmt --to=iec --format %10f Since these are formatting for human consumption, there are varying preferences etc, and so (variants of) the above are appropriate for aliases, or shell functions if accepting parameters. > I usually use other arguments with 'du'. Your external tool solution > doesn't handle the general case of "du's" output. > > The point was to correct 'du's output, not find a *custom* solution > to correct assumptions made by 'du'. > > Why would you reject something that fixes this problem? There are backwards compatibility issues to consider. cheers, Pádraig. From unknown Thu Sep 11 11:56:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20442: bug+patch: du output misaligned on different terminals Resent-From: Linda Walsh Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 13 May 2015 21:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20442 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: Eric Blake , 20442@debbugs.gnu.org Received: via spool by 20442-submit@debbugs.gnu.org id=B20442.143155298729998 (code B ref 20442); Wed, 13 May 2015 21:37:01 +0000 Received: (at 20442) by debbugs.gnu.org; 13 May 2015 21:36:27 +0000 Received: from localhost ([127.0.0.1]:44136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YseKI-0007nj-6h for submit@debbugs.gnu.org; Wed, 13 May 2015 17:36:26 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:36352 helo=Ishtar.hs.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YseKF-0007nW-Lb for 20442@debbugs.gnu.org; Wed, 13 May 2015 17:36:24 -0400 Received: from [192.168.4.12] (Athenae [192.168.4.12]) by Ishtar.hs.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id t4DLaIl9041814; Wed, 13 May 2015 14:36:21 -0700 Message-ID: <5553C3D2.3080306@tlinx.org> Date: Wed, 13 May 2015 14:36:18 -0700 From: Linda Walsh User-Agent: Thunderbird MIME-Version: 1.0 References: <553E89DA.4060206@tlinx.org> <553EC8DA.50906@draigBrady.com> <553ED0AD.8040004@tlinx.org> <553ED43F.1070705@draigBrady.com> In-Reply-To: <553ED43F.1070705@draigBrady.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Pádraig Brady wrote: > There are backwards compatibility issues to consider. Could you demonstrate any where similar issues wouldn't affect output from 'ls' Second, I don't remember numfmt being part being part of posix, but my solution seems to fall under POSIX: From: Pádraig Brady Subject: Re: du: POSIX mandating a single space instead of tab? Date: Tue, 28 Apr 2015 16:51:06 +0100 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 On 28/04/15 15:42, Eric Blake wrote: >>> No, the space stands for any (positive) amount of white space. >>> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html#tag_05 >>> Andreas. >> >> Thanks for pointing that out Andreas. >> So a ' ' in a format implies any amount of blank chars. > > Correct. > >> So we could separate the du columns with spaces rather than tab, > > Yes, I'd prefer that we did that. It is much easier to guarantee > alignment when using spaces and completely avoiding whatever tab stops > people have set up. ===== I find myself agreeing with Eric on this issue. Actually, I would prefer a envvar USE_TABS=[[ytfnx]] (yes true false/no/false/no/expand) and their upper-case versions for simplicity as defaulting to 8 space/tab -- though I could also support the absence of 'USE_TABS' as being compatible with current functionality. I can see the use of something like this in desktop programs tty/consoles, editors, etc... I would want to see standard column terminology (ala sort & cut ranging from 1 - 80). If the var is undefined, I think it would be _more_ _predictable_ to go go with expanded as '8', OR with like the tty_tabs command w/no args: it shows you the current settings. (Why doesn't 'tabs' show them?) However -- it we agree on the env-var for tab presence/expansion and tabstop definitions, I could also agree on leaving behaviors in current programs the same as they are now (w/o the USE_TABS envvar). > tabs tabs: no tab-list given --- hmmm not too useful > tabs 2 -- also tabs doesn't take columns but spaces of separation. Tabstops are usually at set points like 1/2" or 1/4" or some fixed number, so if I use tabs 2:, One might like 'tabs' to display the current tabs: > tty_tab (from 1, tabs skip to column: 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 80 I note the tab program also supports irregular tabs: for i in a a2 c c2 c3 f p s u;do tabs -$i tty_tab done (from 1, tabs skip to column: 10 16 36 72 80 (from 1, tabs skip to column: 10 16 40 72 80 (from 1, tabs skip to column: 8 20 55 80 (from 1, tabs skip to column: 6 10 14 49 80 (from 1, tabs skip to column: 6 10 22 26 30 34 38 42 46 50 54 58 62 67 80 (from 1, tabs skip to column: 7 11 15 19 23 80 (from 1, tabs skip to column: 5 9 13 17 21 25 29 33 37 49 53 80 (from 1, tabs skip to column: 10 55 80 (from 1, tabs skip to column: 12 20 44 80 ----------------- I would like to see this in an ENV var so people could use it for other utils in their session (like vim/emacs or whatever). Some files like the /etc/fstab file really need variable tabs. From unknown Thu Sep 11 11:56:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20442: bug+patch: du output misaligned on different terminals Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 23 Oct 2018 02:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20442 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 20442@debbugs.gnu.org Received: via spool by 20442-submit@debbugs.gnu.org id=B20442.1540261097664 (code B ref 20442); Tue, 23 Oct 2018 02:19:01 +0000 Received: (at 20442) by debbugs.gnu.org; 23 Oct 2018 02:18:17 +0000 Received: from localhost ([127.0.0.1]:36740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEmGu-0000AQ-N7 for submit@debbugs.gnu.org; Mon, 22 Oct 2018 22:18:16 -0400 Received: from mail-io1-f45.google.com ([209.85.166.45]:38157) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEmGr-00006n-T0; Mon, 22 Oct 2018 22:18:14 -0400 Received: by mail-io1-f45.google.com with SMTP id q18-v6so6275090iod.5; Mon, 22 Oct 2018 19:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=uLoU7OmlL6rQk+cC8cKZJaWOwBFtsuWj7jXou1QLI6U=; b=QRXhGBxzQWKDJz+PFSf6wxHZDx/XEgDgqyqbX7OWkVjI1k2wMAkcm6+dX1IGvA1GGl CpBnMK8AlqwVTt+hZWzwXDPvcfAH+sY1SUokwOR+Vk3l4BZc1FLjUCHIZG8HeOWKTIgj BgGuK7KPKoWDCSy/UsQZ/auifGL9FVLY8sWzyxkUkZImnd4Jgt3SVaNYLK+qHCkJE8BL pdNekkDTBEdHVM1p8q2oBMetCaAnLoIO2wkhD0sRa1hD/pg1Ml/NYeT0dLytBsC0F2fq Hs8QkLv6fGRiRRvW9VR8qSyJKmYm2VFrNDQO7nWtmunih7mZEqAlYYlcP+oU1T7kLE/l aNJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=uLoU7OmlL6rQk+cC8cKZJaWOwBFtsuWj7jXou1QLI6U=; b=MMUE9sg4DrZ5/smFeQM7iCe5w4aUndpxFfdmQBBY0T9Ip++dk9rOLPh4uO2Jy3x4Wk jyOCTSu3SD5eGTpLW/1FhQjNyJZCs692RJAx5tmdLG+9Jd4KU91Mx5P30nJAJOToThKA klSzyVnHtX78GdmMQOPZf4+JdKDF1Cnp0OoyVnwpQf44mDubekBSGgs664hpvNZjNXO9 Ahm+tAihxHKdLfhNkYWuUhlXJCYObkZRhsJ70I1wpqf0MAlwHfrhmjy4vb+jgdTclXeF 0KgdUIVtNBXO2C6ATeZZPyz5HCuVZOHz0u+L8NLoHukrTU1iaPDQY+susApOKkmYNTA2 guqw== X-Gm-Message-State: AGRZ1gJN75Mo0Ry9kLNsoI3Jtsuu/MoOQWzucVcSEYcsLMNH9HTr8xZN b+NGqxS/snYoT19XvEF75MbYb1zD X-Google-Smtp-Source: AJdET5cYLjb8niEkBGmlKfizlghV1y4iiBuDJXyNnqCN86pQW+RNCVPyjj+dfTOEh8gqKI6Rq3fzxg== X-Received: by 2002:a5e:8c03:: with SMTP id n3-v6mr6184649ioj.122.1540261087871; Mon, 22 Oct 2018 19:18:07 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id p1sm41781itk.11.2018.10.22.19.18.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 19:18:06 -0700 (PDT) References: <553E89DA.4060206@tlinx.org> <553EC8DA.50906@draigBrady.com> <553ED0AD.8040004@tlinx.org> <553ED43F.1070705@draigBrady.com> <5553C3D2.3080306@tlinx.org> From: Assaf Gordon Message-ID: <37e16a8d-31d7-cc8f-e92d-97d022ba93c8@gmail.com> Date: Mon, 22 Oct 2018 20:18:05 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <5553C3D2.3080306@tlinx.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 20442 wontfix close 20442 stop (triaging old bugs) With not further comments in 3 years (and previous decisions to not fix), I'm closing this bug. regards, - assaf