GNU bug report logs - #78891
Option to make grep always exit with 0

Previous Next

Package: grep;

Reported by: Thomas Güttler Mailinglisten <guettliml <at> gmail.com>

Date: Tue, 24 Jun 2025 14:36:04 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Martin Schulte <gnu <at> schrader-schulte.de>
To: Thomas Güttler Mailinglisten <guettliml <at> gmail.com>
Cc: 78891 <at> debbugs.gnu.org
Subject: bug#78891: Option to make grep always exit with 0
Date: Wed, 25 Jun 2025 08:09:43 +0200
Hello Thomas!

> echo -e "foo\nbar" | { grep '^#' >comments.txt || true; } |
> some-other-command
> 
> Related: My Bash Strict Mode. Handle non-zero exit codes
> <https://github.com/guettli/bash-strict-mode/blob/main/README.md#bash-strict-mode-handle-non-zero-exit-codes>
> 
> This works, but it is not nice to read and more typing.

What about a

grep_always_true() {
  grep "$@" || true
}

?

Best regards,

Martin




This bug report was last modified 50 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.