[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Warn about long lines
From: |
Alejandro Colomar |
Subject: |
Re: Warn about long lines |
Date: |
Tue, 23 Aug 2022 14:17:13 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 |
Hi Ralph,
On 8/23/22 12:37, Ralph Corderoy wrote:
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\}.'
Ahh, I forgot about \{N\}, since I never use it.
Still, the Makefile uses pipefail, so I'm not sure how to make grep(1)
work for this. If it works, it would be nice.
Didn't know about the GNU extension to sed(1)'s q. That would be
simpler than grep(1), since we use pipefail. And I prefer sed(1) over
awk(1).
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.
No, I don't need it.
Thanks!
Alex
--
Alejandro Colomar
<http://www.alejandro-colomar.es/>
OpenPGP_signature
Description: OpenPGP digital signature
- Warn about long lines, Alejandro Colomar, 2022/08/21
- Re: Warn about long lines, Ralph Corderoy, 2022/08/22
- Re: Warn about long lines, Alejandro Colomar, 2022/08/22
- Re: Warn about long lines, Ralph Corderoy, 2022/08/23
- Re: Warn about long lines,
Alejandro Colomar <=
- Re: Warn about long lines, Ralph Corderoy, 2022/08/23
- Re: Warn about long lines, Alejandro Colomar, 2022/08/24
- Re: Warn about long lines, Alejandro Colomar, 2022/08/25
- Re: Warn about long lines, Ralph Corderoy, 2022/08/26
- Re: Warn about long lines, Alejandro Colomar, 2022/08/26
- Re: Warn about long lines, Ingo Schwarze, 2022/08/27
- Re: Warn about long lines, Ralph Corderoy, 2022/08/27
- Re: Warn about long lines, Alejandro Colomar, 2022/08/27
- Re: Warn about long lines, G. Branden Robinson, 2022/08/27
- Re: Warn about long lines, Alejandro Colomar, 2022/08/28