From unknown Sun Jun 22 22:02:03 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#20120 <20120@debbugs.gnu.org> To: bug#20120 <20120@debbugs.gnu.org> Subject: Status: wc output padding differs when "-" is in the file list Reply-To: bug#20120 <20120@debbugs.gnu.org> Date: Mon, 23 Jun 2025 05:02:03 +0000 retitle 20120 wc output padding differs when "-" is in the file list reassign 20120 coreutils submitter 20120 Eric Mrak severity 20120 normal tag 20120 wontfix thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 16 12:22:18 2015 Received: (at submit) by debbugs.gnu.org; 16 Mar 2015 16:22:18 +0000 Received: from localhost ([127.0.0.1]:48770 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YXXmT-0000t5-EX for submit@debbugs.gnu.org; Mon, 16 Mar 2015 12:22:18 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48639) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YXNoW-0000PH-Eh for submit@debbugs.gnu.org; Mon, 16 Mar 2015 01:43:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXNoV-0006oF-0Q for submit@debbugs.gnu.org; Mon, 16 Mar 2015 01:43:44 -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.0 required=5.0 tests=BAYES_40,HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:38920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXNoU-0006oB-Tm for submit@debbugs.gnu.org; Mon, 16 Mar 2015 01:43:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXNoT-0004Y3-Oj for bug-coreutils@gnu.org; Mon, 16 Mar 2015 01:43:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXNoO-0006nU-GU for bug-coreutils@gnu.org; Mon, 16 Mar 2015 01:43:41 -0400 Received: from sender1.zohomail.com ([74.201.84.155]:30432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXNoO-0006nE-8i for bug-coreutils@gnu.org; Mon, 16 Mar 2015 01:43:36 -0400 Received: from mail-ie0-f172.google.com (mail-ie0-f172.google.com [209.85.223.172]) by mx.zohomail.com with SMTPS id 14264846121508.172067505160726; Sun, 15 Mar 2015 22:43:32 -0700 (PDT) Received: by iecsl2 with SMTP id sl2so161317534iec.1 for ; Sun, 15 Mar 2015 22:43:31 -0700 (PDT) Received: by 10.107.144.9 with HTTP; Sun, 15 Mar 2015 22:42:59 -0700 (PDT) X-Received: by 10.107.12.150 with SMTP id 22mr95690304iom.71.1426484611161; Sun, 15 Mar 2015 22:43:31 -0700 (PDT) MIME-Version: 1.0 From: Eric Mrak Date: Sun, 15 Mar 2015 22:42:59 -0700 Message-ID: Subject: wc output padding differs when "-" is in the file list To: bug-coreutils@gnu.org Content-Type: multipart/alternative; boundary=001a113ee2f286a8de05116154ce X-ZohoMailClient: External X-Zoho-Virus-Status: 2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x 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: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 16 Mar 2015 12:22:15 -0400 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: -4.0 (----) --001a113ee2f286a8de05116154ce Content-Type: text/plain; charset=UTF-8 It seems that whenever STDIN is involved the results padding reverts to the BSD-style 7/8 padding. When files are given as input (excluding STDIN) the padding reflects the width of the largest count. When files are given as input and one of these is "-", the padding reverts again to the BSD 7/8 padding. System: Arch Linux (package: core/coreutils 8.23-1) =================== $ wc --version wc (GNU coreutils) 8.23 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Paul Rubin and David MacKenzie. =================== Actual: =================== $ echo "some text" > test.txt $ printf %s "one\ntwo\nthree" | wc - test.txt 3 3 14 - 1 2 10 test.txt 4 5 24 total =================== Expected: =============== $ echo "some text" > test.txt $ printf %s "one\ntwo\nthree" | wc - test.txt 3 3 14 - 1 2 10 test.txt 4 5 24 total =================== --001a113ee2f286a8de05116154ce Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
It seems that whenever STDIN is involved th= e results padding reverts to the BSD-style 7/8 padding. When files are give= n as input (excluding STDIN) the padding reflects the width of the largest = count. When files are given as input and one of these is "-", the= padding reverts again to the BSD 7/8 padding.

System: Arch Linux (package: core/coreutils 8.23-1)

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
$ wc --version
wc (GNU coreutils) 8.23
Copyright (= C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3= or later <http://gnu.org/l= icenses/gpl.html>.
This is free software: you are free to change = and redistribute it.
There is NO WARRANTY, to the extent permitted by la= w.

Written by Paul Rubin and David MacKenzie.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

A= ctual:

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
= $ echo "some text" > test.txt
$= printf %s "one\ntwo\nthree" | wc - test.txt
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 3 =C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 3=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 14 -
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 2=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 10 test.txt
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 4=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 5= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 24 total
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D

Expected:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
$ echo "some text" > test.txt
<= div class=3D"gmail_default" style=3D"font-size:small">$ printf %s "one\ntwo\nthree" | wc - test.txt
=C2=A03=C2=A0 3 14 -
=C2=A01=C2=A0 2 10 test.txt
=C2=A04=C2=A0 5 24 total
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D
--001a113ee2f286a8de05116154ce-- From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 19 05:20:08 2015 Received: (at 20120) by debbugs.gnu.org; 19 Mar 2015 09:20:08 +0000 Received: from localhost ([127.0.0.1]:52440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YYWcZ-0005ux-2z for submit@debbugs.gnu.org; Thu, 19 Mar 2015 05:20:07 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:51062) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YYWcW-0005uo-Mj for 20120@debbugs.gnu.org; Thu, 19 Mar 2015 05:20:05 -0400 Received: from [10.0.4.15] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue102) with ESMTPSA (Nemesis) id 0Lgpny-1ZLLiG3pfK-00oIiC; Thu, 19 Mar 2015 10:20:03 +0100 Message-ID: <5509BBBD.9060005@bernhard-voelker.de> Date: Wed, 18 Mar 2015 18:54:05 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Eric Mrak , 20120@debbugs.gnu.org Subject: Re: bug#20120: wc output padding differs when "-" is in the file list References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:HrEsWs4FLXiF1Ua1wXUYLswHt9DtRYvXYZwyMT4jBLXSDxXMhTM H7QQxJJACc8qlzlT1G7rkh0TRBAF727MCzjjwwZxBmCgMdftLnZzei21R1p+pfYnzEGRjOZ OYWAFPxxboY5f+B4yMT3aR5S2broyKDP/bwAGXFObMhJpctTOSgKjjNsBbYHb3E+jwQwmt/ 7LDDwG2HmE5o1Ix9/2CMA== X-UI-Out-Filterresults: notjunk:1; X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 20120 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.8 (/) On 03/16/2015 06:42 AM, Eric Mrak wrote: > It seems that whenever STDIN is involved the results padding > reverts to the BSD-style 7/8 padding. When files are given > as input (excluding STDIN) the padding reflects the width of > the largest count. > When files are given as input and one of these is "-", the > padding reverts again to the BSD 7/8 padding. Thanks for the report. This effect is there at least since the last bigger change in this area, the introduction of the function compute_number_width(), back in 2003. Furthermore, strange formatting also happend in other cases, e.g. for other non-regular files ... $ wc /etc/hosts /dev/null 41 124 1355 /etc/hosts 0 0 0 /dev/null 41 124 1355 total ... or where stat() returns a wrong value like for /proc files ... $ wc /proc/cpuinfo x 52 256 1276 /proc/cpuinfo 1 0 1 x 53 256 1277 total ... or with the --files0-from=FILE option: $ printf '%s\0' x /etc/hosts | wc --files0=- 1 0 1 x 41 124 1355 /etc/hosts 42 124 1356 total The number width is determined before reading the actual files. I'm asking myself if it would hurt to save the values for all files until all of them are read, and then do the calculation of the number width and the printing of all values. OTOH this would delay output until all files are read (besides the memory footprint). Any opinions if a proper output format warrants this disadvantages? Regarding the number width fallback of %7d: this is mentioned in the POSIX specification (in 'Rationale'), but I'm unsure if it's mandated/ recommended/deprecated behavior. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/wc.html Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 19 06:38:18 2015 Received: (at 20120) by debbugs.gnu.org; 19 Mar 2015 10:38:18 +0000 Received: from localhost ([127.0.0.1]:52504 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YYXqE-0007so-4V for submit@debbugs.gnu.org; Thu, 19 Mar 2015 06:38:18 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:61185) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YYXqB-0007sf-Ub for 20120@debbugs.gnu.org; Thu, 19 Mar 2015 06:38:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj0JAJmmClVtTWSG/2dsb2JhbABcgwZSWoMNwweEaERGAQICgUlMAQEBAQEBfYQPAQEBAwEjDwFLCwsNAQoCAgUWCwICCQMCAQIBRQYBDAgBAYgjDAEIsUqFaZYTAQoBAQEegSGJdoR4gmiBRQWUN4caOoVEC40EIoNuPjEBgkIBAQE Received: from unknown (HELO localhost.localdomain) ([109.77.100.134]) by mail2.vodafone.ie with ESMTP; 19 Mar 2015 10:38:12 +0000 Message-ID: <550AA713.6060509@draigBrady.com> Date: Thu, 19 Mar 2015 10:38:11 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Bernhard Voelker , Eric Mrak , 20120@debbugs.gnu.org Subject: Re: bug#20120: wc output padding differs when "-" is in the file list References: <5509BBBD.9060005@bernhard-voelker.de> In-Reply-To: <5509BBBD.9060005@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 20120 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 18/03/15 17:54, Bernhard Voelker wrote: > On 03/16/2015 06:42 AM, Eric Mrak wrote: >> It seems that whenever STDIN is involved the results padding >> reverts to the BSD-style 7/8 padding. When files are given >> as input (excluding STDIN) the padding reflects the width of >> the largest count. >> When files are given as input and one of these is "-", the >> padding reverts again to the BSD 7/8 padding. > > Thanks for the report. > This effect is there at least since the last bigger change in > this area, the introduction of the function compute_number_width(), > back in 2003. > > Furthermore, strange formatting also happend in other cases, > e.g. for other non-regular files ... > > $ wc /etc/hosts /dev/null > 41 124 1355 /etc/hosts > 0 0 0 /dev/null > 41 124 1355 total > > ... or where stat() returns a wrong value like for /proc files ... > > $ wc /proc/cpuinfo x > 52 256 1276 /proc/cpuinfo > 1 0 1 x > 53 256 1277 total > > ... or with the --files0-from=FILE option: > > $ printf '%s\0' x /etc/hosts | wc --files0=- > 1 0 1 x > 41 124 1355 /etc/hosts > 42 124 1356 total > > The number width is determined before reading the actual files. > I'm asking myself if it would hurt to save the values for all files > until all of them are read, and then do the calculation of the > number width and the printing of all values. > OTOH this would delay output until all files are read (besides > the memory footprint). > Any opinions if a proper output format warrants this disadvantages? Changing to unbounded memory (albeit slowly increasing) is not worth it I think. > Regarding the number width fallback of %7d: this is mentioned in > the POSIX specification (in 'Rationale'), but I'm unsure if it's > mandated/ recommended/deprecated behavior. > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/wc.html The existing padding is only a nicety. If I was going to change anything, I'd add field selection and left/right alignment support to column(1). cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 22 22:01:18 2018 Received: (at 20120) by debbugs.gnu.org; 23 Oct 2018 02:01:18 +0000 Received: from localhost ([127.0.0.1]:36659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEm0T-0005Kd-Vl for submit@debbugs.gnu.org; Mon, 22 Oct 2018 22:01:18 -0400 Received: from mail-it1-f180.google.com ([209.85.166.180]:40023) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEm0S-0005FI-Lv; Mon, 22 Oct 2018 22:01:16 -0400 Received: by mail-it1-f180.google.com with SMTP id i191-v6so64045iti.5; Mon, 22 Oct 2018 19:01:16 -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=4x4kVhdCUz7aRbcJoC/aXgY+lrPJ1WJcuHxbyQX2FSM=; b=d1Ayxwy6D4prVp6EsXr7NsXSwV3atmlaG2kLD2ukidmKUF3MCfI2Jj6vOAKiDvk7SG VaT7vKr9wIxOGtrtz3ibcO4D7MUKMGJkyj9OhStle/xC1hnHNtMdC8lYGoMKJHxFobGj SkDTjCDW+IuafBE4pPTwQvZyQTggBx/dXVnUGDTP8Kn8A9SCRsbYwDN3FyoQOkG6s33b 0ccdW0R4Mon6dLlO1dXwk/bYLVes67FmkGagjrMVJy7WuxNTFRI52MGmHVqHwbZR3xFt R7a5hHTO6nrsYhd1mGZbncEzv5uIYgXmBAOoS9TM+4XZY8XpyIBZXPOQVeFYJPw0bIFZ 1KrA== 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=4x4kVhdCUz7aRbcJoC/aXgY+lrPJ1WJcuHxbyQX2FSM=; b=se30WVehDZITbxc8Rq9VpJORkVH5kQHIy3oQDLAhlchtocSKUBKiWeDsIXeqzJbb32 LR2Fx0MS+k30FgCUVl5/yTBimiJLqS6bTQzxHzbL0/OIbw0MMXi1rbORGi42qc2vsyrK sXXXuNcGI7yJCPS/usjR6YzjiOvJBDbm81k2rtvF+KuJk3LP//M4y3xOyZJii5dxGLGd QunZ2LprgZLDhFCqKW0KSxBG65Wru+ZDgOmseFiKj+OHqKp4vmD05kaOEtoPNGxT1oBP pbh2W2UMOaKlENyIuPX4QuzIp1HCY+amHiKbXbWMu8VluX1VDqbSdG/0mo5KBxZW8Vap ZsyA== X-Gm-Message-State: ABuFfohiiLZfwVT2HwM47o9ywFKZOlJc+/iDjb/wo5N/iccqhzFF4rl4 73ADgyA9PdSqFaE9HB5b5x3FI4PB X-Google-Smtp-Source: ACcGV60T3OyuWk96LbjKAR7fIJ9OkIOt8TMM7qPgtroSUtI26gSSFhHqPOfegyXzNBeciLAGO1PdOQ== X-Received: by 2002:a05:660c:441:: with SMTP id d1mr11396802itl.22.1540260070354; Mon, 22 Oct 2018 19:01:10 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id e78-v6sm6313825itc.4.2018.10.22.19.01.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 19:01:09 -0700 (PDT) Subject: Re: bug#20120: wc output padding differs when "-" is in the file list To: 20120@debbugs.gnu.org References: <5509BBBD.9060005@bernhard-voelker.de> <550AA713.6060509@draigBrady.com> From: Assaf Gordon Message-ID: <34eccbe6-9b8b-79ed-d2a9-f587796e7006@gmail.com> Date: Mon, 22 Oct 2018 20:01:07 -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: <550AA713.6060509@draigBrady.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 20120 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 20120 wontfix close 20120 stop (triaging old bugs) On 19/03/15 04:38 AM, Pádraig Brady wrote: > On 18/03/15 17:54, Bernhard Voelker wrote: >> On 03/16/2015 06:42 AM, Eric Mrak wrote: >>> It seems that whenever STDIN is involved the results padding >>> reverts to the BSD-style 7/8 padding. >> >> Thanks for the report. >> This effect is there at least since the last bigger change in >> this area, the introduction of the function compute_number_width(), >> back in 2003. > > The existing padding is only a nicety. > If I was going to change anything, I'd add field selection and left/right > alignment support to column(1). Given the above, and without further comments in 3 years, I'm closing this bug. Discussion can continue by replying to this thread. -assaf From unknown Sun Jun 22 22:02:03 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 20 Nov 2018 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator