Re: grep: add option for better usability in pipelines

2022-02-16 Thread Kang-Che Sung
On Thu, Feb 17, 2022 at 3:27 PM Ulrich Eckhardt wrote: > > > > 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 > `grep -p ...` rather replaces `grep ... || test $? = 1`. The advantage > is that it is

Re: grep: add option for better usability in pipelines

2022-02-16 Thread Kang-Che Sung
On Thu, Feb 17, 2022 at 12:50 PM Michael Conrad wrote: > > On 2/16/22 19:32, Kang-Che Sung 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

Re: grep: add option for better usability in pipelines

2022-02-16 Thread Ulrich Eckhardt
On Thu, 17 Feb 2022 08:32:06 +0800 Kang-Che Sung wrote: > On Thu, Feb 17, 2022 at 8:01 AM Ulrich Eckhardt > 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

Re: grep: add option for better usability in pipelines

2022-02-16 Thread Michael Conrad
On 2/16/22 19:32, Kang-Che Sung 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 If there are no issues in

Re: grep: add option for better usability in pipelines

2022-02-16 Thread Kang-Che Sung
On Thu, Feb 17, 2022 at 8:01 AM Ulrich Eckhardt wrote: > > I've implemented a `-p` flag for grep, which disables a behaviour that > the exit status is used (abused?) to signal whether any match > occurred. The behaviour is POSIX. > Now, for an example where it makes a difference. Consider a

grep: add option for better usability in pipelines

2022-02-16 Thread Ulrich Eckhardt
Greetings! I've implemented a `-p` flag for grep, which disables a behaviour that the exit status is used (abused?) to signal whether any match occurred. In many cases, you won't notice this. Also, in many cases, shell scripts don't check for errors. Now, for an example where it makes a