[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wc feature request
From: |
A B |
Subject: |
Re: wc feature request |
Date: |
Tue, 6 Oct 2020 23:49:19 -0400 |
I mean if you want to get picky about it and have this work exactly like grep
-q, then you need to make the flag accept a threshold value, which it should
match or exceed.
So maybe: wc -l -q3
That doesn’t have the same intuitive feel to me, but it wouldn’t violate the
notion of how exit codes should be used either.
-Alex Boese
Sent from my Triceratops.
> On Oct 6, 2020, at 2:19 PM, Kaz Kylheku (Coreutils)
> <962-396-1872@kylheku.com> wrote:
>
> On 2020-10-05 08:40, A B wrote:
>> Many thanks for all the much needed contributions to society as a whole.
>> I did have one feature to request for wc, which I think would be
>> highly complementary to grep’s -q flag. It would be really cool if wc
>> could have a -q flag as well, which could return matches within a
>> predefined threshold as the exit code itself. So for example, if I
>> wrote ‘wc -l -q’ at the end of a pipe, then no output would be
>> returned, but the exit code would return a 3 if three lines were
>> found.
>
> I don't see this exact feature in the documentation of GNU grep.
> grep terminates with a 0 status (success) when matches are found,
> and this is true with -q.
>
> The idea has limited applicability; there are only as few as 8 bits
> (or fewer?) available in the process status word for encoding the
> exit code.
>
> It could be useful for counting the number of lines or characters
> in files that are somehow guaranteed to be small.
>
> The inversion of the exit success polarity is also troubling.
> If nothing is counted, that's 0 (success), whereas if anything
> is counted, that is a termination failure.
>