Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 945110 - [Future EAPI] Wrapper for command exit status
Summary: [Future EAPI] Wrapper for command exit status
Status: CONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Package Manager Specification
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: future-eapi
  Show dependency tree
 
Reported: 2024-11-27 12:20 UTC by Ulrich Müller
Modified: 2024-12-21 07:01 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.