delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/02/02/21:52:09

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 409EA3858D37
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=tlinx.org
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tlinx.org
Message-ID: <61FB4315.8040204@tlinx.org>
Date: Wed, 02 Feb 2022 18:51:01 -0800
From: L A Walsh <cygwin AT tlinx DOT org>
User-Agent: Thunderbird
MIME-Version: 1.0
To: Thomas Wolff <towo AT towo DOT net>
Subject: Re: ls -C broken
References: <a57bb847-ac3e-7620-234c-1c3babc21fdf AT towo DOT net>
In-Reply-To: <a57bb847-ac3e-7620-234c-1c3babc21fdf@towo.net>
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
SPF_HELO_NONE, SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Cc: cygwin AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

On 2022/01/28 07:46, Thomas Wolff wrote:
> If I redirect output of `ls -C` (file / pipe), it used to produce 
> well-formatted output in columns.
> Suddenly it produces garbage formatting instead. As `ls` itself is not 
> new, maybe it's some library that breaks behaviour?
> Or even pty code?? Works on Cygwin 32-bit. Any idea?
> Thomas
>   
---
The authors of Gnu ls changed 'ls' defaults because "they can".

Old ls -C:
/bin/ls /proc
331  379  913       filesystems  mounts      registry32  swaps    version
332  500  cpuinfo   loadavg      net         registry64  sys
335  731  cygdrive  meminfo      partitions  self        sysvipc
new ls -C:
 /bin/ls /proc|cat
331
332
335
370
379
500
731
732
945
946
cpuinfo
cygdrive
devices
filesystems
loadavg
meminfo
misc
mounts
net
partitions
registry
registry32
registry64
self
stat
swaps
sys
sysvipc
uptime
version

---
with column:
law.Bliss> /bin/ls /proc|column (tabs mismatch)
331   731   devices   net   stat
332   732   filesystems partitions  swaps
335   952   loadavg   registry  sys
370   953   meminfo   registry32  sysvipc
379   cpuinfo   misc    registry64  uptime
500   cygdrive  mounts    self    version

with column+expand -8:
s> /bin/ls /proc|column|expand -8
1021            379             devices         net             stat
1022            500             filesystems     partitions      swaps
331             731             loadavg         registry        sys
332             732             meminfo         registry32      sysvipc
335             cpuinfo         misc            registry64      uptime
370             cygdrive        mounts          self            version


---
several other tools no longer have settings to expand tabs to user-values
requiring the use of expand.

Formats of numeric output were also changed, requiring usage of 'numfmt'

This was all done to benefit script consistency at the expense of
users usability. It is expected that users can adapt to the computers.







by default, 'ls' will produce different output when it goes to the 
screen vs. when
it goes to a pipe.  When 'ls' goes to a pipe it is required to only use 
1 column.

To get the behavior you want, try piping through 'column' first (see 
'man (1) column).

They made many changes in core-utils to make automated shell scripts more
consistent at the expense of user-usability where they now suggest using
pipes into other utilities to get previous output

Try using ls|column.  Of course ls also used to expand tabs to every 8 
characters
and it no longer does that.  So you must use another util 'tabs' to set 
tabs to every
8th column (ls's standard tab setting)

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019