groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warn about long lines


From: Ralph Corderoy
Subject: Re: Warn about long lines
Date: Tue, 23 Aug 2022 11:37:05 +0100

Hi Alejandro,

> Thunderbird doesn't seem to like me.

Oh, yes, it didn't occur to me it had been split in transit.

> >      $ groff -Tutf8 -man -ww longline.man |
> >      > awk 'length > 80 {print; e = 1} END {exit e}'
> >        this is a very long line that will go past the 80-col right margin, 
> > and I want to be warned about it.
> >      $ echo $?
> >      1
> >      $
>
> I like that use of awk(1)!
> I was never an awk(1) user, but this one I can't seem to replace it with 
> simpler tools.  Seems like the tool for the job!

Oh, that was just the first way my fingers thought of.
sed(1) could do it with the GNU extension of an exit code to ‘q’.
But easiest and fastest is probably plain old grep(1).
Note the inversion of grep's exit code with ‘!’, assuming this is
bash(1) and ‘pipefail’ is not set.

    ! groff -Tutf8 -man -ww longline.man |
    expand |
    grep '^.\{80\}.'

I don't think expand(1) is required here as grotty(1) only puts uses
tabs with ‘-h’, but I thought it deserved mention in case your set up is
different.

-- 
Cheers, Ralph.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]