Subject: Re: fmt utility from NetBSD
To: John Darrow <John.P.Darrow@wheaton.edu>
From: Aleksey Cheusov <cheusov@tut.by>
List: tech-userlevel
Date: 04/29/2006 13:10:21
> On 24 Apr 2006 13:27:13 -0500, Aleksey Cheusov <cheusov@tut.by> wrote:
 >> >> I personally think that GNU fmt -s option is useful.
 >> >> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 >> >>        -s, --split-only
 >> >>               split long lines, but do not refill
 >> >> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 >>
 >>> FOLD(1)          NetBSD General Commands Manual             FOLD(1) 
 >>Unfortunately, 'fold -s' != 'GNU fmt -s'
 >>
 >>0 ~>printf '   q w e r t y u i o p\n' | fold -s -w 10
 >>   q w e 
 >>r t y u i 
 >>o p
 >>
 >>0 0 ~>printf '   q w e r t y u i o p\n' | gfmt -s -w 10
 >>   q w
 >>   e r t
 >>   y u i
 >>   o p
 >>
 >>0 0 ~>

> NetBSD's default fmt (using goal of 9, max of 10, as goal and max
> can't be equal):

 >>0 0 ~>printf '   q w e r t y u i o p\n' | fmt 9 10
>    q w e
>    r t y
>    u i o
>    p
This is not the same to fold -s, I need wrapping too long lines only
without mixing it.
0 ~>printf '   q w e r t y u i o p .\n   a s d f g h j k l .\n' | fmt 9 10
   q w e
   r t y
   u i o
   p .  a
   s d f
   g h j
   k l .

0 ~>

I expect something like
   q w e
   r t y
   u i o
   p .
   a s d
   f g h
   j k l
   .

> Personally, I don't like gfmt's shorting the first line to make the
> last line longer.
Agree.


> While we're here, though, I think that fmt(1) should have an Xr to
> fold(1), as I often think of the former command first when I really
> want the latter's behavior (e.g. _not_ copying the first line indent
> to the later lines).  An Xr from fold to fmt wouldn't hurt either.
This is matter of tastes and applications,
both options are useful and can (should?)
be implemented in fmt.
For my needs it is probably easier to extend fold utility, but fmt.

Another problem is that only NetBSD and MS Interix fmt use
such a strange way to pass options.
Most other fmt implementations use more widely used -option <val>
style, i.e. 'fmt -w 10 [files...]'
Default NetBSD fmt is very different from other fmt implementations.

-- 
Best regards, Aleksey Cheusov.