[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: grep: add option for better usability in pipelines
From:       Bernd Petrovitsch <bernd () petrovitsch ! priv ! at>
Date:       2022-02-17 8:40:03
Message-ID: 10df817f-82e5-fc0d-7b17-10135d9c381a () petrovitsch ! priv ! at
[Download RAW message or body]

Hi all!

On 17.02.2022 08:27, Ulrich Eckhardt wrote:
> On Thu, 17 Feb 2022 08:32:06 +0800
> Kang-Che Sung <explorer09@gmail.com> wrote:
>> On Thu, Feb 17, 2022 at 8:01 AM Ulrich Eckhardt
>> <ulrich.eckhardt@base-42.de> wrote:
>>> Now, for an example where it makes a difference. Consider a Bash
>>> script like this:
>>>
>>>    # enable automatic error handling
>>>    set -eo pipefail
>>>    # check for string "issues" in a logfile
>>>    cat logfile | grep issue | sort --unique

And useless use of cat ....

[...]
>> Why do we need to implement a workaround in grep while you can
>> do this in shell to ignore the exit code of grep?
>>
>> { grep issue <logfile || :; } | sort --unique
> 
> `grep -p ...` rather replaces `grep ... || test $? = 1`. The advantage
> is that it is explicit about what it does. Understanding the intent of
> `-p` or `--pipe` is easier than understanding the alternative.

1st: It's quite the opposite:
The alternative is, not POSIX and not even existent in GNU-grep.
The : exists in /bin/sh as a built-in since 2 generations and no need to 
look up some new option.

2nd: busybox is about size - not featuritis (aka bloat).

Kind regards,
	Bernd
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic