Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 945110

Summary: [Future EAPI] Wrapper for command exit status
Product: Gentoo Hosted Projects Reporter: Ulrich Müller <ulm>
Component: PMS/EAPIAssignee: Package Manager Specification <pms>
Status: CONFIRMED ---    
Severity: normal CC: esigra, flow, kfm, kuraga333, mgorny, sam
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=566342
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 174380    

Description Ulrich Müller gentoo-dev 2024-11-27 12:20:57 UTC
This was suggested in bug 566342 comment #30; filing a separate bug for it.

> In my opinion, even adding a wrapper to coalesce grep exit status would be a
> cleaner approach here, however bad an idea that is.

So the idea would be to add a wrapper (name and exact API to be discussed) that would map a given (single, or list of) exit status to 0, as in this example:

$ true | map_status 1 grep foo | true; pipestatus; echo $?
0

Then again, doing this explicitly isn't much longer, e.g. the second command in the example above could be replaced by "{ grep foo || [[ $? -eq 1 ]]; }".

Also, are there any use cases other than grep? As pointed out by mgorny, in many cases sed can be used instead of grep, in order to avoid exit status 1.
Comment 1 Ulrich Müller gentoo-dev 2024-11-27 12:36:04 UTC
(In reply to Ulrich Müller from comment #0)
> Also, are there any use cases other than grep? As pointed out by mgorny, in
> many cases sed can be used instead of grep, in order to avoid exit status 1.

If there aren't, we could alternatively think of just adding a wrapper for grep that would return 0 instead of 1. (Unfortunately, the name "egrep" is already taken ...)

Again, not sure if it's worth the effort.