X-Loop: help-debbugs@HIDDEN
Subject: bug#79497: fmt breaks lines when it does not need to
Resent-From: Bruno Haible <bruno@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-coreutils@HIDDEN
Resent-Date: Tue, 23 Sep 2025 09:47:01 +0000
Resent-Message-ID: <handler.79497.B.175862081023385 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 79497
X-GNU-PR-Package: coreutils
X-GNU-PR-Keywords:
To: 79497 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-coreutils@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.175862081023385
(code B ref -1); Tue, 23 Sep 2025 09:47:01 +0000
Received: (at submit) by debbugs.gnu.org; 23 Sep 2025 09:46:50 +0000
Received: from localhost ([127.0.0.1]:40238 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1v0zbm-000654-4l
for submit <at> debbugs.gnu.org; Tue, 23 Sep 2025 05:46:50 -0400
Received: from lists.gnu.org ([2001:470:142::17]:60466)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <bruno@HIDDEN>) id 1v0zbe-00064X-RD
for submit <at> debbugs.gnu.org; Tue, 23 Sep 2025 05:46:43 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <bruno@HIDDEN>) id 1v0zbW-00048q-0L
for bug-coreutils@HIDDEN; Tue, 23 Sep 2025 05:46:35 -0400
Received: from mo4-p07-ob.smtp.rzone.de ([85.215.255.114])
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <bruno@HIDDEN>) id 1v0zbQ-0006mr-6w
for bug-coreutils@HIDDEN; Tue, 23 Sep 2025 05:46:33 -0400
ARC-Seal: i=1; a=rsa-sha256; t=1758620782; cv=none;
d=strato.com; s=strato-dkim-0002;
b=BdV16PziZM46yuRQyS+NTn3A+PO7m6KV6f1gGeCAAFbpees3yNZmSaQgiZKQIU6eUj
6bydGLWeefg2cQiblpwAH+yHt4Nl21ARDYOYkF6rFZ1fbmSGAJcv6WTDiqrJmSJn5/y5
Pw+b28m624VO5m81YRFn3G6I+YCauIskqXOeDlDRX08yI419yh2UByaBR7lJ4apeDYP4
x33vog4x3sHGrSSTQFo1nEMs55RjIOKRMnSuDim1aWvlIoV/puA3fjnHiaMSHbm+R/8A
KRJCFzyMTAkp/3f7j/q7BxVpNJoZLDxplRx1oUMNqqrBjPQAgDos6WmlE5UJFL+1V4wk
cr+Q==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1758620782;
s=strato-dkim-0002; d=strato.com;
h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender;
bh=/jYWVrpIX/sW7Ym/ODpK15HlmMlFzy5LM5IfdFcKSqk=;
b=TtSow04HwcBQvPPMeddpHUSQKnrDh+aOuzg/w92zkRvCRCB2WNUS003VV93mnBis+D
aK9dPNxjtCWpkWdPeUouaGsRAYJYpcK68KueK2QOVOtlFpZkHcJjJiUHXgFVGb+qS08S
yzApFXFkN5KsDnC6ELDiqCbHUSAuuO6tBBqJwQcgiwbMdVyEprA0rYX1wC1I9usIPGSt
8Tekki5FYZF/0nfzqnn2BdJHb4mV0DYBejfkpqUS7dEZE42urUEv3otclHp19k+cokkb
J8C46QS8WwRIUEmQgmYTVIuRXp0iwZCflNAklNddFrHo+rbKbXKHN0Jj29BuswAs74tt
A4AA==
ARC-Authentication-Results: i=1; strato.com;
arc=none;
dkim=none
X-RZG-CLASS-ID: mo07
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1758620782;
s=strato-dkim-0002; d=clisp.org;
h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender;
bh=/jYWVrpIX/sW7Ym/ODpK15HlmMlFzy5LM5IfdFcKSqk=;
b=Vnuu7qbpWjBYHFH0FrCHWqi7mo+SKp5Q/3LX/TwwJ3WnCHmE+N5V4QCCdWA+yjBtST
25yYHuBDabpzYK7EFJDyqPQOLX2c99DuoNXfGLfFjbTczpHbSGKwkrxK0PWOlYWHjx5n
V319gW67VrsEPeMUCR/eUjjSF/2D3eQCT0XyMifuTHNOTsTRp2doAuJlFw+xw9jo/ZJm
ssnnATjGVMDZaPTNsE4iIfgNxtaHUpuXT5x5NOFFWi0TYv5SJ4TiSUaRACJZQTRrLIVb
iZXZAvxz0xi2XNOiqF/ma2zHO4dP9uSfnrF4Toji10V9M8QO2fH3ekQSNf2SCNs8UDJN
f8Eg==
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlLnY4jECd2hdUURIbZgL8PX2QiTuZ3cdB8X/nqjjPETjapHX+9l3zLlh16XTrnZwC"
Received: from nimes.localnet by smtp.strato.de (RZmta 53.3.2 AUTH)
with ESMTPSA id N0828e18N9kM22j
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits))
(Client did not present a certificate);
Tue, 23 Sep 2025 11:46:22 +0200 (CEST)
From: Bruno Haible <bruno@HIDDEN>
Date: Tue, 23 Sep 2025 11:46:21 +0200
Message-ID: <2419308.IPqQCg1nHW@nimes>
Organization: GNU
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="nextPart19763405.gIjEHFZm8d"
Content-Transfer-Encoding: 7Bit
Received-SPF: none client-ip=85.215.255.114; envelope-from=bruno@HIDDEN;
helo=mo4-p07-ob.smtp.rzone.de
X-Spam_score_int: 4
X-Spam_score: 0.4
X-Spam_bar: /
X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MIME_CHARSET_FARAWAY=2.45,
RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001,
RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001,
SPF_NONE=0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)
This is a multi-part message in MIME format.
--nextPart19763405.gIjEHFZm8d
Content-Transfer-Encoding: base64
Content-Type: text/plain; charset="UTF-8"
SGksCgpXaXRoIHRoZSBhdHRhY2hlZCBpbnB1dCBmaWxlIGFuZCBjb3JldXRpbHMtOS44LCBJIHNl
ZSB0aGVzZQpyZXN1bHRzIGZyb20gdGhlICdmbXQnIGNvbW1hbmQsIGluIHRoZSBlbl9VUy5VVEYt
OCBsb2NhbGUKb24gYSBHTlUgc3lzdGVtOgoKJCBmbXQgLXcgMTIgLWcgMTIgaW5wdXQudHh0Ckdy
w7zDnwpHb3R0LgrQl9C00YDQsNCy0YHRgtCy0YPQudGC0LUhCng9KC1iwrFzcXJ0KGLCsi00YWMp
KS8oMmEpCuaXpeacrOiqnizkuK3mlocs7ZWc6riACiQgZm10IC13IDEzIC1nIDEzIGlucHV0LnR4
dApHcsO8w58gR290dC4K0JfQtNGA0LDQstGB0YLQstGD0LnRgtC1IQp4PSgtYsKxc3FydChiwrIt
NGFjKSkvKDJhKQrml6XmnKzoqp4s5Lit5paHLO2VnOq4gAoKV2h5IGRvZXMgaXQgdGFrZSBhIHdp
ZHRoIG9mIDEzLCBpbiBvcmRlciB0byBrZWVwIHRoZSBmaXJzdCB0d28gd29yZHMKb24gYSBzaW5n
bGUgbGluZT8gVGhhdCBsaW5lIGhhcyB3aWR0aCAxMC4KCkkgd291bGQgZXhwZWN0IHRoYXQgYWxy
ZWFkeSAnZm10IC13IDEwIC1nIDEwIGlucHV0LnR4dCcga2VlcHMgdGhlc2UKdHdvIHdvcmRzIHRv
Z2V0aGVyLgoKQnJ1bm8KCg==
--nextPart19763405.gIjEHFZm8d
Content-Disposition: attachment; filename="input.txt"
Content-Transfer-Encoding: base64
Content-Type: text/plain; charset="x-UTF_8J"; name="input.txt"
R3LDvMOfIEdvdHQuINCX0LTRgNCw0LLRgdGC0LLRg9C50YLQtSEgeD0oLWLCsXNxcnQoYsKyLTRh
YykpLygyYSkgIOaXpeacrOiqnizkuK3mlocs7ZWc6riACg==
--nextPart19763405.gIjEHFZm8d--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Bruno Haible <bruno@HIDDEN> Subject: bug#79497: Acknowledgement (fmt breaks lines when it does not need to) Message-ID: <handler.79497.B.175862081023385.ack <at> debbugs.gnu.org> References: <2419308.IPqQCg1nHW@nimes> X-Gnu-PR-Message: ack 79497 X-Gnu-PR-Package: coreutils Reply-To: 79497 <at> debbugs.gnu.org Date: Tue, 23 Sep 2025 09:47:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-coreutils@HIDDEN If you wish to submit further information on this problem, please send it to 79497 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 79497: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D79497 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN
Subject: bug#79497: fmt breaks lines when it does not need to
Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady <P@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-coreutils@HIDDEN
Resent-Date: Tue, 23 Sep 2025 11:17:02 +0000
Resent-Message-ID: <handler.79497.B79497.175862617614803 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 79497
X-GNU-PR-Package: coreutils
X-GNU-PR-Keywords:
To: Bruno Haible <bruno@HIDDEN>, 79497 <at> debbugs.gnu.org
Received: via spool by 79497-submit <at> debbugs.gnu.org id=B79497.175862617614803
(code B ref 79497); Tue, 23 Sep 2025 11:17:02 +0000
Received: (at 79497) by debbugs.gnu.org; 23 Sep 2025 11:16:16 +0000
Received: from localhost ([127.0.0.1]:40784 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1v110J-0003qe-FE
for submit <at> debbugs.gnu.org; Tue, 23 Sep 2025 07:16:15 -0400
Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:45309)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.84_2) (envelope-from <pixelbeat@HIDDEN>)
id 1v110E-0003oP-BG
for 79497 <at> debbugs.gnu.org; Tue, 23 Sep 2025 07:16:11 -0400
Received: by mail-wm1-x333.google.com with SMTP id
5b1f17b1804b1-46cf7bbfda8so15177125e9.2
for <79497 <at> debbugs.gnu.org>; Tue, 23 Sep 2025 04:16:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1758626163; x=1759230963; darn=debbugs.gnu.org;
h=content-transfer-encoding:in-reply-to:from:content-language
:references:to:subject:user-agent:mime-version:date:message-id
:sender:from:to:cc:subject:date:message-id:reply-to;
bh=U3BjhMtlodTZbraQkdmnVhtDPA7n6gGlHk08rHUOj5Q=;
b=E6DEtJdYbUVXEZeYgENVoL/+iAzesO3F7arr2iwHFGQveukfNVzqPfE0zRmzJwn0Tm
F2W/jmugLO9ZuGre2hCSYen5R0IZ1+1fgzZQl/6K+PMGdvWkwC3O+qHHonN2qcAdsUd5
/aP2MmFgL2gYSIvwrwEtnO0DVZJ5WcV8+BRrvqEta/XQXgTafjbUYyWBOKTbs+Ii6d6C
139AHqU7Q7oc7txuwWpUuEoPTkEoXhfo6IbJRKvnI+Ym8lAu3LSwHFwKMqtL47CfsdMF
ToHjezjaukrRk7qhUbxCMgxNo4ByMHJd0CLCxEv3S88JLvxsAIhSjRyDHrIYqACitY4l
pp9Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1758626163; x=1759230963;
h=content-transfer-encoding:in-reply-to:from:content-language
:references:to:subject:user-agent:mime-version:date:message-id
:sender:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=U3BjhMtlodTZbraQkdmnVhtDPA7n6gGlHk08rHUOj5Q=;
b=OdeEIPwJ6z2VV8cwAc112+9efebs1EnVitS0kv9vnOFaO26tRCEDnkYIte0DGw0n76
vqp+0Dex5Hladcoq82oNpK+jGM+xgENv4xq+Wyr1c6+Hd6h+Tfp0iExLD7jQvGoERD/z
Wlzf63aKf5j7uyWWVF4IDFtpdtrLjMfInNOEs+Sba42JsQ1zFsa99ommWd7aQFfb8hrC
BDT/SusfC0zd/WxXyk9EUuQQi+urz3j6w8PDrcjWT5TrgdgSymD68bnSiiBuBM7O5KoO
nuLs+c++3AeCsnYlN2CduwZj28MGRfO7a0bM6MmtG99p6/WktdJWf/EMz5sDIoAKBro1
N2Iw==
X-Forwarded-Encrypted: i=1;
AJvYcCW95iAM6BZLMKKx+ufndRwtnggkZH7pfdj8EgZSJDn5iPC9goFvKYnrAlgqG87feyZqQbfudQ==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yxq3Wkhvzm6WbOD4AqboYoMdUTJ+96IdB4eEaRdyMB28PUeYlGo
yHyH/LnD2C5jDUeszKsqyufb9uOYS65jqqfpuWYNo3+zKiEqlDFr00zV
X-Gm-Gg: ASbGncuNGkshVAW0BlzJf2OdrmRD9c6KyoK+u7yAbFjs3l6l8RC1+yovEdUV9dXVYeR
MS16mKDi5bzd3HeX0YnI8YIuDFB4QINDADNeLFdoGENvz0FhbidJZl1IwJJxli+V7xi7n+syYrE
FZ1EGN7dtTjFa63TcIYB48i+A0aABlCuobkWW9MjsH2gC+EBFDhuRvoiJTLMiQ5rPDqyNqOu+aj
hIiiQ4OdW9sgPCDG90II7GmRYabjmQyhuT+iL0jRrvbubeYtiLi0vKcj+roLOjmCAPpHakGKIkF
okQkBIIo8wl3i3COjIz2tM9pKS8uUKiwOJnkMaWnUHVI37ft8ZwQyD7/WHWjn8UoXrTY4OPG0l2
HzNr8HcOyWmD8CK4eFjkuZsnGViL3aUyn2r28Bow0TaCdOPVnwhlnx8wg9NULZK1ksJXVkNIRdL
1tXcY=
X-Google-Smtp-Source: AGHT+IHjJr5A/A2QJVc9KXgm495tP5e7RdV3Khfwvgo6gMp7mnlLDsJwecx/VtI76miT/ae9qJ3Nlg==
X-Received: by 2002:a05:600c:a02:b0:45b:4a98:91cf with SMTP id
5b1f17b1804b1-46e1daa1207mr21346705e9.15.1758626163099;
Tue, 23 Sep 2025 04:16:03 -0700 (PDT)
Received: from [192.168.1.31]
(86-44-211-146-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.44.211.146])
by smtp.googlemail.com with ESMTPSA id
5b1f17b1804b1-46e1dc3c53dsm11927165e9.7.2025.09.23.04.16.02
(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
Tue, 23 Sep 2025 04:16:02 -0700 (PDT)
Message-ID: <b1c55522-44c8-4f26-9ede-207d3279e0e8@HIDDEN>
Date: Tue, 23 Sep 2025 12:16:01 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird Beta
References: <2419308.IPqQCg1nHW@nimes>
Content-Language: en-US
From: =?UTF-8?Q?P=C3=A1draig?= Brady <P@HIDDEN>
In-Reply-To: <2419308.IPqQCg1nHW@nimes>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)
On 23/09/2025 10:46, Bruno Haible via GNU coreutils Bug Reports wrote:
> Hi,
>
> With the attached input file and coreutils-9.8, I see these
> results from the 'fmt' command, in the en_US.UTF-8 locale
> on a GNU system:
>
> $ fmt -w 12 -g 12 input.txt
> Grüß
> Gott.
> Здравствуйте!
> x=(-b±sqrt(b²-4ac))/(2a)
> 日本語,中文,한글
> $ fmt -w 13 -g 13 input.txt
> Grüß Gott.
> Здравствуйте!
> x=(-b±sqrt(b²-4ac))/(2a)
> 日本語,中文,한글
>
> Why does it take a width of 13, in order to keep the first two words
> on a single line? That line has width 10.
>
> I would expect that already 'fmt -w 10 -g 10 input.txt' keeps these
> two words together.
Well the 10 vs 13 is due to fmt not being multi-byte aware
(only fold(1) got the multi-byte treatment in coreutils 9.8).
But yes there are still confusing things here.
The man page says -w counts characters,
while the info page says -w counts columns.
The code seems to follow the man page and includes the \n in the char count.
Note fold -w does not count the newline which is what I'd expect.
We could change to that behavior without much compat issue I think.
$ printf '%s' 'aafd as fd d' | wc -c 12
$ printf '%s' 'aafd as fd d' | git/coreutils/src/fmt -w12 -g12
aafd as
fd d
$ printf '%s' 'aafd as fd d' | git/coreutils/src/fmt -w13 -g13
aafd as fd d
BTW I see fmt is not part of POSIX
cheers,
Padraig
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.