Bug 309131 - output of wc has been changed
Summary: output of wc has been changed
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: coreutils   
(Show other bugs)
Version: 4.5
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Ondrej Vasik
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2007-09-27 14:47 UTC by Chuck Mead
Modified: 2008-08-12 12:23 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-08-12 12:23:10 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Chuck Mead 2007-09-27 14:47:25 UTC
Description of problem: Under rhel3 wc -l /etc/passwd would output with 3 spaces
in front of the numeric line count. Under rhel4 it does not. I cannot find
anything in the changelog for rhel4's coreutils to explain the difference in the
output and it is breaking pre-existing scripts.

Version-Release number of selected component (if applicable):
coreutils-4.5.3-26 on rhel3
coreutils-5.2.1-31.6 on rhel4

How reproducible:

Steps to Reproduce:
1. run wc -l /etc/passwd on rhel3
2. run wc -l /etc/passwd on rhel4
3.  On rhel4 it does not.
Actual results:
The output on rhel4 has no leading spaces/

Expected results:
The output on rhel3 has leading spaces.

Additional info: This breaks scripts and it is an undocumented change.

Comment 1 Chuck Mead 2007-09-27 15:13:22 UTC
I checked the changelogs at gnu and the --changelog output from rpm -q coreutils
and I cannot find any mention of why this change was made... was it inadvertent?

Comment 2 Pete Graner 2007-09-27 15:26:17 UTC
This is documented in:


  wc count field widths now are heuristically adjusted depending on the input
  size, if known.  If only one count is printed, it is guaranteed to
  be printed without leading spaces.

  Previously, wc did not align the count fields if POSIXLY_CORRECT was set,
  but POSIX did not actually require this undesirable behavior, so it
  has been removed.

It is also documented in: info wc

However, as a GNU extension, if only one count is printed, it is
guaranteed to be printed without leading spaces.

Comment 3 Chuck Mead 2007-09-27 15:27:54 UTC
Yeah I found the discussion at
http://lists.gnu.org/archive/html/bug-coreutils/2003-07/msg00098.html with the
evil patch which "broke" the previous behavior.

Comment 4 Ondrej Vasik 2008-08-12 12:23:10 UTC
Missed that bugzilla completely for a while. Looking at previous comments and error description, it looks like notabug for me. Change in behaviour is documented in info documentation and release NEWS file. Closing NOTABUG.

Note You need to log in before you can comment on or make changes to this bug.